[SERVER-29526] Updating the specific array in nested subdocument Created: 09/Jun/17  Updated: 09/Jun/17  Resolved: 09/Jun/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Maniratnam Katakam Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-27089 Extend the update subsystem to suppor... Closed
Related
related to SERVER-29515 Invalid "cannot use part of (results ... Closed
Operating System: ALL
Participants:

 Description   

Hello All,

I have a similar situation I guess, the following is the sample Json document in which I need to query on.

{
    "_id" : ObjectId("591d601fc9f360331cd4668c"),
    "Type" : "district",
    "GroupId" : "00000000-0000-0000-0000-000000000456",
    "Grades" : [ 
        {
            "GroupId" : "gs00000000-0000-0000-0000-000000000452",
            "Categories" : [ 
                {
                    "Sequence" : 1,
                    "Low" : 0,
                    "High" : 99,
                    "Min" : 0,
                    "Max" : 0,
                }, 
				 {
                    "Sequence" : 1,
                    "Low" : 50,
                    "High" : 99,
                    "Min" : 0,
                    "Max" : 0,
                }
            ]
        }
    ],
    "NumberOfTypes" : 4,
    "CreatedDate" : ISODate("2017-05-18T08:49:35.433Z"),
    "LastModifiedDate" : ISODate("2017-05-26T16:12:52.093Z"),
    "Status" : true
}

I need to pick all the document where the value of "Low": 0 and change to 1. I am trying the following query

db.BenchmarkDetails.update(
    {"Grades.Categories.Low" : 0},
    {$set : 
            {"Grades.Categories.$.Low" : 1}
     }
     )

This throwing the error

cannot use the part (Grades of Grades.Categories.0.Low) to traverse the element.



 Comments   
Comment by Kelsey Schubert [ 09/Jun/17 ]

Hi katakam.maniratnam@gmail.com,

Thanks for your reporting this issue. We're working on improving array updates for MongoDB 3.6. Please free feel to watch SERVER-27089 for updates. See also the conversation on SERVER-29515 regarding recent work in this space.

Thanks again,
Thomas

Generated at Thu Feb 08 04:21:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.