I want to update address based on _id for the nested array object in below document:
{
"_id": "fb369348-341b-11e9-9e05-03b09392591c",
"user": [
{
"_id": "fb369349-341b-11e9-9e05-03b09392591c",
"name": "test1",
"address": [
{
"_id": "fb369350-341b-11e9-9e05-03b09392591c",
"loc1": "place1, chennai, India",
"type": "home"
},
{
"_id": "fb369351-341b-11e9-9e05-03b09392591c",
"loc1": "palce2, chennai, India",
"type": "work"
}
]
},
{},
{},
{}
]
}
I am using below query in mongodb its working fine and the record is getting updated:
db.user_details.update(
{ "user.address._id": 'fb369350-341b-11e9-9e05-03b09392591c' },
{ $set: {
"user.$.address.$[i].loc1": "11111111111",
"user.$.address.$[i].type": "fdfdfddfdfdfdfdfdfdfdf"
}
},
{ arrayFilters: [{ "i._id": 'fb369350-341b-11e9-9e05-03b09392591c'}] }
)
but when I am trying to use the above query in node js I am getting the error:
TypeError: Cannot read property 'castForQuery' of undefined
Can anyone help me to understand why I am getting a castForQuery error, _id is uuid and saved as string type?