Hello,
imagine the following scenario:
{
testId:"abc123",
name:"object1",
colors:[
{
colorId:1,
name: Blue,
description: "This is blue"
},
{
colorId:2,
name: Green.
description: "This is green"
}
]
}
I want to be able to perform an upsert based on the following contraints:
- if testId does not exist, inserts a new root document.
- if testsId exists, check colors. if colorId exists, update existing color, else inserts new element in colors array.
I am able to solve this problem using several separate operations such as:
find the document by testId, perform update and then upsert.
Can this be performed in a single operation using mongodb c# driver? What would be the best way, performance-wise, to do this?
Thanks in advance