exports.index = function(req, res) {
console.log('collec req', req.query.queryObject)
Collection.all(req.user._id, function(err, collections) {
if (!err) {
console.log('collections', collections);
Vote.find( {user: req.user._id}, function(err, votes) {
if (!err) {
for (var i = 0; i < votes.length; i++) {
for (var j = 0; j < collections.length; j++) {
console.log('collection match')
if (collections[j]['whiskey'] == votes[i]['whiskey']) {
collections[j]['voteId'] = votes[i]['_id'];
collections[j]['userVote'] = votes[i]['vote'];
}
}
}
res.send(collections);
}
});
};
},
req.query);
};
对于上述函数,console.log指示何时存在匹配,但userVote未添加到匹配的集合中。