I have a collection that has a structure that looks like the following
{ "_id" : "MHBk8q96vpuRYrAdn",
"circles" : {
"guests" : 3,
"properties" : [
{
"position" : { "x" : 146, "y" : 70.5207970},
"name" : "circle-1"
},
{
"position" : { "x" : 200, "y" : 85},
"name" : "circle-2"
}
],
"tables" : 1
}
}
I need to be able to either update the position of circles.properties.position if it exists by name, or add a new entry if it does not. For example, update the position of "circle-1" since it exists, but add a new array item for "circle-3" with a name and position. Is it possible to achieve this? So far I have only been able to push onto the array using $push, and I have messed around with the $(query) operator with no success. Thanks.