Created
March 25, 2021 17:09
-
-
Save HonbraDev/19d9041f8e0f25b088060e335410c28c to your computer and use it in GitHub Desktop.
FireGreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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