Seeking assistance with streaming all documents from a mongoDB collection to my website. Here's the code snippet in question:
mongoClient.connect('mongodb://localhost:27017/database', function(err, db) {
if (err) throw err
var cursor = db.collection("Users").find();
while(cursor.hasNext()){
res.write(cursor.next())
}
res.end()
Encountering the error "first argument must be a string or buffer". How can I properly convert the data retrieved into a string for parsing?