5

Is it possible to use an update query with a where clause in Azure Cosmos DB using SQL-like logic like is in this statement?

Update Tasks set Tasks.name='Update My Task' 
where Tasks.categoryId='695c9592-a42b-48a9-b266-1cfd55490a0a'
and Tasks.taskOrder >=1

I see that there is no SQL Query equivalent, but is there a way to perform what's logically equivalent to an efficient UPDATE -- a PATCH, not a PUT?

ruffin
  • 16,507
  • 9
  • 88
  • 138
amethianil
  • 480
  • 2
  • 7
  • 16
  • Given that `UPDATE` and `DELETE` fall into the same category (in the context of query vs modification), I marked this as duplicate, since it's already been answered. – David Makogon Mar 24 '18 at 13:52
  • 2
    @DavidMakogon Thanks! I knew that it was answered before somewhere (and that too by you) but was too lazy to search :). Deleted my answer. – Gaurav Mantri Mar 24 '18 at 14:16
  • I'm not sure `DELETE` and `UPDATE` are the same beasts. Right now, there's nothing I can find (eg, [this from MSDN](https://docs.microsoft.com/en-us/rest/api/cosmos-db/restful-interactions-with-cosmosdb-resources)) to suggest a `PUT` is *or isn't* as expensive as a `DELETE`. But they sure as heck are different questions. A `PUT` doesn't *have* to be a `DELETE` plus `POST`, and you could, at some point, have a `PATCH` REST API endpoint. At the very least, there should be an answer that says, "Currently, there is no concept of a targeted update in Cosmos." If that's true, I'd like confirmation. – ruffin Sep 26 '18 at 17:02

0 Answers0