Here is code that send array of cards to client.
var cards = Card.find().sort('-created').exec(function (err, cards) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(cards);
}
});
Model Card have a field "ownerName" (it's empty in database) and "ownerId" (id of some user). For each card I need to find a user by card.ownerId and assign its name to field "ownerName". How can I do it?