Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-12001

Documentation of $[<identifier>] contradicts documentation of update

      ----------------------------

      Original Description

      In the documentation of the $[<identifier>] operator, section Update All Array Elements that Match Multiple Conditions, it states:

      To modify the value of the std field for all elements in the grades array where both the grade is greater than or equal to 80 and the std is greater than or equal to 5, use the positional $[<identifier>] operator and arrayFilters:

      db.students.update(
         { },
         { $inc: { "grades.$[elem].std" : -1 } },
         { arrayFilters: [ { "elem.grade": { $gte: 80 }, "elem.std": { $gt: 5 } } ], multi: true }
      )
      

      However, isn't that contradictory to what it is explained in the update operation documentation with regards to arrayFilter?:

      You can include the same identifier multiple times in the update document; however, for each distinct identifier ($[identifier]) in the update document, you must specify exactly one corresponding array filter document. That is, you cannot specify multiple array filter documents for the same identifier. For example, if the update statement includes the identifier x (possibly multiple times), you cannot specify the following value for arrayFilters:

      [ { "x.a": { $gt: 85} }, { "x.b": { $gt: 80 } } ]
      

      ----------------------------

      Description

      Scope of changes (files that need work and how much)

      Impact to other docs outside of this product

      MVP (work and date?)

      Resources (e.g. Scope Docs, Invision)

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            dacucar Dario Cutillas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              5 years, 24 weeks, 1 day ago