Bulk.find.arrayFilters() is not working with mongodb nodejs driver. 3.0.7.

196 views
Skip to first unread message

Atha

unread,
Apr 20, 2018, 12:35:42 PM4/20/18
to mongodb-user
error:  bulk.find(...).arrayFilters is not a function.

I am using "Bulk.find(<query>).arrayFilters([ <filter1>, ... ]).updateOne(<update>);" function.

Wan Bachtiar

unread,
May 23, 2018, 8:57:27 PM5/23/18
to mongodb-user

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.

Reply all
Reply to author
Forward
0 new messages