SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

PATCH db/coll/docid when no document found #276

Closed kpetros closed 6 years ago

kpetros commented 6 years ago

According to documentation, it seems to me that PATCH db/coll/docid shouldn't perform upserts. When there is no document matching the id, i expect a 404 NOT FOUND response. Instead, a new document is created and the response code is 201 CREATED. PATCH db/coll/docid return codes

I use version 3.2.2

ujibang commented 6 years ago

All write requests, including patch have upsert semantic.

To avoid creating a document, you can use a bulk PATCH

PATCH /db/coll/*?filter={ condition }  { "foo": "bar" }

To avoid updating a document you can pass the query parameter checkEtag

PATCH /db/coll/docid?checkEtag

This returns 412 Precondition Failed if document with _id=docid exists. See http://restheart.org/learn/etag/