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);
};
For the above function, the console.log indicates when there is a match, but the userVote is not being added to the matching collection.