I'm using MongoDB 4.0 via the latest C# driver (v2.7.0 at this time). I have a document which has Options and Options have Inventory. So in other words, an array of inventory is nested within an array of options. How do I get down to the inventory level and update the inventory only?
Here's what my document looks like in JSON form:
{
"Options": [
{
"Id": 1,
"Description": "This is one option",
"Inventory": [
{
"Id": 1,
"Name": "Box of stuff"
},
{
"Id": 2,
"Name": "Another box of stuff"
}
]
},
{
"Id": 2,
"Description": "This a second option",
"Inventory": [
{
"Id": 1,
"Name": "Box of stuff"
},
{
"Id": 2,
"Name": "Another box of stuff"
}
]
}
]
}
Using the C# driver, how do I change the name of a single inventory item within a single option, if I know the Id of the option and the Id of the inventory item?