Skip to content

Instantly share code, notes, and snippets.

@olafkotur
Created January 29, 2020 20:29
Show Gist options
  • Save olafkotur/1f19d5d57a33f4f620fe92abe9f6258f to your computer and use it in GitHub Desktop.
Save olafkotur/1f19d5d57a33f4f620fe92abe9f6258f to your computer and use it in GitHub Desktop.
Promises in Typescript
const data: ILiveData[] = await <any>MongoService.findOne('live', {});
findOne: async (collection: string, query: any) => {
return new Promise((resolve: any) => {
database.collection(collection).findOne(query, (error: Error, res: any) => {
if (error) {
throw error;
}
resolve(res);
});
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment