DocumentDB: What's the point of "Upsert"?

Viewed 19295

I'm trying to understand this part of the API so I can update documents in the most efficient way possible.

Given the following:

  • "Replace" requires that a document already exists
  • "Upsert" doesn't require that a document exists, but needs the document ID if it's going to do an update.
  • Neither command can do partial document updates, which means I can't think of any scenario where I wouldn't have to query the document first, then make the change to the affected property, then replace/upsert the entire document.

If I always have to query the document first anyway so as to avoid wiping out any property values that aren't passed back to the upsert/replace, and I can't do a partial updates, what's the point of having both upsert and replace?

Am I missing the intended use cases for these two commands?

1 Answers
Related