Skip to content

Instantly share code, notes, and snippets.

@HonbraDev
Created March 25, 2021 17:09
Show Gist options
  • Save HonbraDev/19d9041f8e0f25b088060e335410c28c to your computer and use it in GitHub Desktop.
Save HonbraDev/19d9041f8e0f25b088060e335410c28c to your computer and use it in GitHub Desktop.
FireGreSQL
import db from "../libs/database";
import { DBUserProfile } from "./types";
const getUser = (id: string): Promise<DBUserProfile> =>
new Promise((res, rej) =>
db
.ref("users")
.orderByChild("id")
.equalTo(id)
.once("value", (snap) => {
const value = snap.val();
if (value) {
res(value[Object.keys(value)[0]]);
} else rej();
})
);
export default getUser;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment