error: bulk.find(…).arrayFilters is not a function.
Hi Athar,
It’s been a while since you posted your question, have you found a solution yet ?
The arrayFilters()
is a helper method on mongo shell. See also Bulk.find.arrayFilters()
If you’re using MongoDB Node.js Driver v3.0.x, you can utilise bulkWrite method instead of the Bulk API.
For example, given documents:
{_id:1, y:[{a:1, b:3}, {a:2 ,b:1}]}
{_id:2, y:[{a:1, b:0}, {a:2, b:1}]}
You can update the first document with value of b:3
to b:10
using the following snippet:
let operations = [{updateOne:{filter: {},
update:{"$set":{"y.$[i].b":10}},
arrayFilters:[{"i.b":3}]}
}];
collection.bulkWrite(operations, function(err, result){
assert.equal(null, err);
});
Regards,
Wan.