From the course: Microsoft Azure Cosmos DB Developer Specialty (DP-420) Cert Prep: 1 Design and Implement Data Models by Microsoft Press

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Implement an update by using a patch operation

Implement an update by using a patch operation

Now, this, again, is an important exam alert for you to know about. That I showed you that a typical upsert operation is where you're basically just replacing the whole document and adding some to it. That's still the case. But the Version 3 .NET SDK for Cosmos allows you to do a patch operation, also called a partial document update. So this gives you path-level updates to specific files and properties in a single item. As I said, it's called the partial document update, and the API is called the Patch API. And this is an alternative to the traditional upsert in which you read a document, execute optimistic concurrency control checks to where Cosmos can do what it can to make sure that nobody else, no other writer is attempting to operate on the document, update the document locally, and then send a whole document replacement to Cosmos. Now, how does partial document update or the Patch API differ? I think it makes more sense intuitively. Let me know what you think. Here we have a…

Contents