Stream from a mongodb cursor to Express response in node.js

Use the cursor stream in combination with JSONStream to pipe it to your response object.

cursor.stream().pipe(JSONStream.stringify()).pipe(res);

Leave a Comment