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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: manual, Server
    • Labels:

      Description

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

      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)

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Days since reply:
              2 years, 48 weeks, 4 days ago
              Date of 1st Reply: