Skip to content

Instantly share code, notes, and snippets.

@fed135
Last active February 19, 2020 16:36
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 fed135/a52eaf95839a8bdab02ca05fc49e4209 to your computer and use it in GitHub Desktop.
Save fed135/a52eaf95839a8bdab02ca05fc49e4209 to your computer and use it in GitHub Desktop.
Mongo stream helper
const { promisify } = require('util');
const stream = collection.find();
const next = promisify(stream.nextObject);
let row;
while(null !== (row = await next(stream))) {
// do stuff with your row
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment