Im using Azure Cosmos DB to store data in the following format.
{
"id": "id",
"name": "Name",
"items": [
{
"id": "id",
"name": "name"
}
]
}
Im using Azure Functions and JavaScript to add to this document db, and this is working as expected.
Now I would like to add a new product into the array products
.
Is this even possible, without recreating the whole document?
I would really just like to send two inputs like this.
Input 1
{
"id": "A",
"name": "Name A",
"items": [
{
"id": "01",
"name": "Item A"
}
]
}
Input 2
{
"id": "A",
"name": "Name A",
"items": [
{
"id": "02",
"name": "Item B"
}
]
}
Result
{
"id": "A",
"name": "Name A",
"items": [
{
"id": "01",
"name": "Item A"
},
{
"id": "02",
"name": "Item B"
}
]
}
Maybe im using it wrong, maybe the products
should have been normalized into a separate document?
Is this even possible, without recreating the whole document?
Partial updates to a document is not possible. You will need to fetch the existing document, update it and then save the entire document again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With