1

Am using it with nodejs in my backend. Got the following query:

db.conversations.update( 
    { convoId: convoId },
    { $set: { "ids.$[elem].read" : true } },
    { arrayFilters: [ { "elem.id": userId } ] }, (err, data) => {
    if(err) {
        res.send(err);
    }
    console.log(data);
    res.json(data);
});

Now in the frontend i get the error back, when the query is finished:

"No array filter found for identifier 'elem' in path 'ids.$[elem].read'"

I read, that array filters don't work if the mongodb version is below 3.6, so i updated that but it still gives me the same error.

Anyone got an idea what i'm doing wrong?

Favo SA
  • 13
  • 3
  • 1
    I see `mongojs` in the tags of your question. Chances are this is not actually using an updated core driver. I suggest looking at the compatibility matrix and in fact really using the [core driver instead](https://mongodb.github.io/node-mongodb-native/). See also the notes at the end of [How to update multiple array elements with MongoDB](https://stackoverflow.com/a/46054172/2313887) as if you "upgraded" then you possibly have a "feature compatibility" setting problem. – Neil Lunn Nov 01 '18 at 21:29

1 Answers1

1

looks like npm mongodb version is 2.* as it is using driver 3.4.2 version. Please upgrade mongodb package above or 3.0.2 version for working with 3.6 mongodb features.