I am trying to update my addresses into my person data:
if _, ok := update["addressName"]; ok {
request = bson.M{"addresses": bson.M{"addressName": update["addressName"]}}
} else {
request = update
}
_, err = people.UpdateOne(context.TODO(), filter, bson.M{"$set": request})
this doesn't create an object in the array,
I want to have a result like this:
{
"updateAt": TIME_NOW
"addresses": [
{"addressName": "ONLY", default: true},
{"addressName": "ONLY", default: true}
]
}
how is the correct way to request for an object in array with MongoDB Driver?