bguerout/jongo

Unable to use 'arrayfilters' option in the update Query

Gnaneshwar511 opened this issue · 6 comments

MongoDB has this feature to give the ability to update a/the part(s) of subarray.

MongoDB Manual

It is done with the use of 'arrayfilters' and I think it starts from Mongo3.6 version.

My question on Stackoverflow for better understanding of the situation

I can see that same feature doesn't work on using Jongo update method. Can we include it in future releases?

hi @bguerout

db.attributes_schema.update({'default.tables._objectId': '5cbf010e53fe' },
{$set:{"default.tables.$[i].schema_definition.$[j].visible": 1}},
{arrayFilters: [{"i._objectId": '5cbf010e53fe'},{"j._objectId": 'ac22d981e8e3'}]});

! com.mongodb.WriteConcernException: Write failed with error code 2 and error message 'No array filter found for identifier 'i' in path 'attributes.default.tables.$[i].schema_definition.$[j].visible''

collection.update("{user: #}", user)
.with("{'$set': {'stepItems.$[i].items.deleteFl': true}}, {'arrayFilters': [{'i.items"
+ "._id': #}]}", user, new ObjectId(planId));

The error:

java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Too many parameters passed to query: {'$set': {'stepItems.$[i].items.deleteFl': true}}, {arrayFilters: [{'i.items._id': #}]}

Looks like it doesn't recognize the values given after 'arrayFilters' as arguments. In short, it isn't recognizing arrayFilters.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.