I am using updateOne to update some of the fields of an object embedded in an array property of a document.

The document itself has a valid _id, which is being used in the query of the updateOne call. The array has multiple elements and arrayFilters are used to isolate the one I want to change.

explain() does not answer this question, the output itself only lists the stages for UPDATE and IDHACK.

db.getCollection('ColName').updateOne({_id: 'validId'}, {'$set': {'array.$[filter].field': 'edited'} }, 
    { 'upsert': false,
      'arrayFilters': [{
        "filter.F1" : "V1",
        "filter.F2" : "V2",
        "filter.F3" : "V3",
        "filter.F4" : "V4",
        "filter.F5" : "V5"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.