Running Update for nested items

To keep it somewhat simple:

The data I’m dealing with is nested like this:

“Location” : {
“Id” : UUID(“8c8860c6-ddf9-45bf-a2b0-d0457e991d0a”),
“Name” : “Lot A”,
“Code” : “A”

There are approx 2500 different instances that I need to update as each of these is tied to another item. What I’m wanting to do is run an updateMany to change the UUID to a New UUID with something like this:

db.getCollection(‘Permits’).updateMany({
“Location.Id.UUID”: {
$in: [
“8c8860c6-ddf9-45bf-a2b0-d0457e991d0a”
]
}
},
{
$set: {
“Location.Id.UUID”: “NEWUUID”
}
},
{
multi: true
})

It doesn’t return errors but also doesn’t update anything. I’m very new to Mongo having come from SSMS an am struggling o this one.

Most likely because

does not match any document.

Most likely because “8c8860c6-ddf9-45bf-a2b0-d0457e991d0a” is a string while

is a UUID. They must have the same type.

1 Like