Created
January 29, 2020 20:29
-
-
Save olafkotur/1f19d5d57a33f4f620fe92abe9f6258f to your computer and use it in GitHub Desktop.
Promises in Typescript
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
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