UpdateOne Using Aggregation Pipeline On Nested Array Fields Leads To Unexpected Outcome

Hi Steeve,

Thanks for your reply.

I am trying to write a generic library code for a CRUD operation that could work for any type of data.

For instances, I should be able to make changes at a List Of List at the nth level (here acquirers.0.facilitators) without having to write a $slice directive for each level. The query would become complicated with each level of array nesting.

Instead if mongoDB could understand the dot notations like it does while updating using $set and array filters, it would make the query much simpler and easier to generify.

Example query with $set and array filter:

db.getCollection("test").updateOne( {_id:1}, {"$set": {"list.$[element].position":3} }, {"arrayFilters":[ {"element.key1":"a"} ] } )

I could have used this query instead but there’s a problem with the change stream being generated when multiple matches & updates happen. I have posted another topic for that.