Reputation: 143
i'm new to mongoose, I want to update my city_name, my schema structure looks like
const addressSchema = new mongoose.schema({
address:{
door_no:{type:number},
other_details:{
street_name:{ type: string},
city:{
city_name:{type:string},
pincode:{type:string},
}
}
}
})
sample db data :
{
"_id": "63dw8sdhs8ad0s",
"address": {
"door_no": 43,
"other_details": {
"street": "sdsadada",
"city": {
"city_name": "dfaef"
}
}
}
}
now i want to update the city_name i tried this query
addressModel.findByIdAndUpdate({_id:id},{$set:{'address.other_details.city.city_name':'44xd3xc'}})
but it doesn't update for me.
Upvotes: 0
Views: 143