Open Szeraax opened 2 years ago
Hi @Szeraax - I just saw that too. I'm hoping the REST API's will be updated with this feature as well: https://docs.microsoft.com/en-us/rest/api/cosmos-db/
Closing for now at least.
Hey @PlagueHO, am I reading this right that we now have PATCH capability in the API?
https://learn.microsoft.com/en-us/rest/api/cosmos-db/patch-a-document
Looks like it is supported now and it requires that you use the Patch method with an array of operations. I think the best way to go about implementing this will be to add a PatchOperation type in our module class and then add a Update-CosmosDbDocument
cmdlet. Update-CosmosDbDocument
would have an optional PartitionKey
string param, an optional conditional filter (probably just use -Filter
for the param name), and would require an array of the [PatchOperation]
objects.
Here is the other document that is helpful to look at: https://learn.microsoft.com/en-us/azure/cosmos-db/partial-document-update
Any guidance on my approach? Cool if I take a first pass at a PR or would you like me to do this in a different way?
Regarding the PatchOperation type, I'd need some help creating that class, since I'm a c# noob at best.
I guess a start would be:
public class PatchOperation {
public System.String op { get; set; }
public System.String path { get; set; }
public System.Object value { get; set; }
}
But we'd need to restrict the op to one of the supported operations like add, remove, set, etc. Not sure how to set a validation set in c#. The path would be a string and that's no problem. But the value
would need to be any object type that can convert to json (string, int, float, etc.). Dunno how to appropriately do that in the strongly typed world of c#.
Announced today, Cosmos has partial update support: https://devblogs.microsoft.com/cosmosdb/partial-document-update-ga/