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

前端 未结 5 1227
死守一世寂寞
死守一世寂寞 2020-11-29 05:12

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=         


        
5条回答
  •  孤街浪徒
    2020-11-29 05:59

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

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

提交回复
热议问题