Last active
February 22, 2018 05:02
-
-
Save t-raku/55fe5b649ec1cf206257f8c919acfb82 to your computer and use it in GitHub Desktop.
a usecase of processing all documents from mongo for each time getting a document
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
// use of mongodb | |
// | |
let collection = mongoClient.db(databaseName).collection(collectionName); | |
let cursor = await collection.find(); | |
while( await cursor.hasNext() ){ | |
let document = await cursor.next(); | |
}; | |
// use of mongoose | |
// | |
let collection = mongoose.connection.collection(collectionName); | |
let cursor = await collection.find(); | |
while( await cursor.hasNext() ){ | |
let document = await cursor.next(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment