Skip to content

Instantly share code, notes, and snippets.

@GoodnessEzeokafor
Created February 17, 2022 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Firebase find query
type FilterQuery<T> = {
[K in keyof T]?: T[K]
};
static async findOne(field: FilterQuery<ITranslation>): Promise<any> {
try {
const results = await this.builder().where(Object.keys(field)[0], "==", Object.values(field)[0]).get();
if (results.length) {
return results[0];
}
return null;
} catch (e) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment