Last active
February 19, 2020 16:36
-
-
Save fed135/a52eaf95839a8bdab02ca05fc49e4209 to your computer and use it in GitHub Desktop.
Mongo stream helper
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 { 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