Skip to content

Instantly share code, notes, and snippets.

@t-raku
Last active February 22, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-raku/55fe5b649ec1cf206257f8c919acfb82 to your computer and use it in GitHub Desktop.
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
// 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