扔信息; TypeError:第一个参数必须是string或缓冲区

我试着这个代码:

app.get('/caminhosRelevantes',function(req,res){ console.log(req.protocol+":/"+req.get('host')); var collection = "caminhos"; var ObjectId = require('mongodb').ObjectID; collectionDriver.getCollection(collection, function(error, the_collection) { if (error) { res.end("<h1>Eerro</h1>"); } else the_collection.aggregate([ { $match: { id_usuario: "54bef57a14b88ad70a8ab74e" } }, { $group: { _id: { rua: "$rua", data: "$data" } } }, { $group: { _id: "$_id.rua", data: { $push: "$_id.data" }, count: { $sum: 1 } } }, { $match: { count: { $gt: 5 } } } ], function(error,doc) { //C if (error) res.end(error); else res.end(doc); }); }); }); 

但我收到以下错误:

 /server/node_modules/mongodb/lib/mongodb/connection/base.js:242 throw message; ^ TypeError: first argument must be a string or Buffer at ServerResponse.OutgoingMessage.write (http.js:851:11) at ServerResponse.OutgoingMessage.end (http.js:985:16) 

我试过res.status(200).send(doc)而不是res.end(doc); 而且效果很好!