vendredi 30 janvier 2015

Adding additional fields to document before response


I have a request that I respond to as such:



function getstuff(req, res) {
var url = require('url').parse(req.url, true).query.u;

Thing.findOne({url: url}, function (err, doc){
doc.newThings = 'some text!';
res.json(doc);
});
}


I'd like to be able to append some additional data to the document before I send it along to the client. The method I've tried above doesn't seem to be working. Is there clean way to accomplish this?





Aucun commentaire:

Enregistrer un commentaire