Reading and updating an existing document with a dynamic object
Now we will write a method that updates the document that represents the second scheduled competition. Specifically, the method changes the values for the dateTime
and numberOfRegisteredCompetitors
keys.
Note
At the time I was writing this book, the only way to update the value of any key in a document stored in a Cosmos DB collection was to replace the document with a new one. Since the first version of Cosmos DB and the SQL API, this is the only way to update the values for keys in a document. In this case, we just need to update the values for two keys, but we will have to replace the entire document.
The following lines declare the code for the UpdateScheduledCompetition
asynchronous static method, which receives the competition ID, its location ZIP code, the new date and time, and the new number of registered competitors in the competitionId
, competitionLocationZipCode
, newDataTime
, and newNumberOfRegisteredCompetitors
arguments...