Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function getReply(replyId){
- let db = await MongoClient.connect(MONGO_URI);
- let testDb = db.db("test");
- let reply = await testDb.collection('replies').findOne({'_id': replyId})
- if (typeof reply.replies !== 'undefined' && reply.replies.length > 0){
- let superArr = reply.replies.map(
- async (replyId) => {
- return await getReply(replyId)
- }
- )
- return superArr
- } else {
- return null
- }
- }
- getReply(ObjectID("5ee29a83b6f54879ebec9f45")).then(
- reply => console.log(reply)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement