I have a document in the following form:
{
"_id" : ObjectId("4d2d8deff4e6c1d71fc29a07"),
"user_id" : "714638ba-2e08-2168-2b99-00002f3d43c0",
"events" : [
{
"profile" : 10,
"data" : "....."
}
{
"profile" : 10,
"data" : "....."
}
{
"profile" : 20,
"data" : "....."
}
...
]
}
I'd like to have some sort of upsert
statement. It needs to add an event
to the events
array for user_id
in case there is already such doc exist, else it needs to create the doc with the event
item.
Can that be done?