I am toying around with all the fancy node.js/mongodb/express platforms, and stumbled across a problem:
app.get(\'/tag/:tag\', function(req, res){
var tag=
A working combination of other answers here
app.get('/comments', (req, res) => {
Comment.find()
.cursor()
.pipe(JSONStream.stringify())
.pipe(res.type('json'))
})
http://mongoosejs.com/docs/api.html#query_Query-cursor
cursor() returns a Node streams3 compatible stream and is preferred over the deprecated query.stream() interface.JSONStream.stringify() to combine documents into an array instead of single objectsres.type('json') which sets the HTTP Content-Type header to application/json and returns itself (the response stream) again.