0

The following query works in the MongoDB console.

db.getCollection('safetyPlan').update({"user": "username"}, {"$set": {"stepItems.$[i].items.deleteFl": true}}, {"arrayFilters": [{"i.items._id": new ObjectId("3w43esrw3er2343rsfsdf333")}]});

The same query written using Jongo:

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

When I try to execute the Java code, it throws:

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

Can someone give me the correct syntax to use arrayFilters using Jongo. I doubt if Jongo supports it.

I'm using Jongo: 1.3.0 and mongo-java-driver: 3.7.1

BraveNinja
  • 203
  • 3
  • 11
  • I would say no at this time. The [wrapper on `update()`](https://github.com/bguerout/jongo/blob/1a7ef982d91a12ff63e761c621494d21cec30291/src/main/java/org/jongo/Update.java) shows that this is still using the legacy API signature and there is no way to pass in an "options" where the `arrayFilters` is actually contained. If you want to use this then you are better off using the main Java driver interfaces directly. Also note that development on this is not very active with very few changes within the last few years. – Neil Lunn Jun 12 '18 at 08:04
  • Thank you for the information. – BraveNinja Jun 12 '18 at 17:33

0 Answers0