0
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.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.