Reputation: 161
I am using mongoDB (version 2.2.36) in Nodejs. The problem is when I try to use array update there is an error "No array filter found for identifier 'rival' in path ...", but when I try it in mongo shell everything is ok. Code in nodejs:
db.get().collection(collectionName).update({ _id: ObjectID(id) }, {$inc: {
"votesCount": 1,
"rivals.$[rival].votes": 1
},
}, { arrayFilters: [{ "rival.id": voteModel.answerId }]}, function (err, docs) {
cb(err, docs);
});
I try to update the version, but 2.2.36 is the latest.
Upvotes: 1
Views: 4263
Reputation: 28326
The MongoDB Node.JS driver version 2.2.36 doesn't have array filter support in the update method.
Starting in version 3.0 update does have the arrayFilters option.
You'll need to upgrade the driver in order to use that option.
Upvotes: 7