Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53896

positional $ operator when there are two array path in query

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL
    • Query Optimization 2021-02-22

      having following document:

      {
        "user": [1],
        "grades": [
          {"grade": 80, "mean": 75, "std": 40},
          {"grade": 85, "mean": 90, "std": 45},
          {"grade": 90, "mean": 85, "std": 50}
        ]
      }
      

       

      this query:

      db.students.updateOne(
        { user: 1, "grades.grade": 85 },
        { $set: { "grades.$.std" : 6 } }
      )
      

       

      update first element in grades instead of second one.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            rahbari@gmail.com Ali Rahbari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: