Skip to content

Commit c628de1

Browse files
PATCH vs. PUT vs. Replace (#2048)
Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
1 parent 389797e commit c628de1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

node.js/cds-serve.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,25 @@ service CatalogService {}
400400

401401
Be aware that using an absolute path will disallow serving the service at multiple protocols.
402402

403+
### PATCH vs. PUT vs. Replace
404+
405+
The HTTP method `PATCH` is meant for partial modification of an _existing resource_.
406+
`PUT`, on the other hand, is meant for ensuring a resource exists
407+
, that is, if it doesn't yet exists, it gets created.
408+
If it does exist, it gets updated to reflect the request's content.
409+
410+
This content, however, may be incomplete.
411+
By default, the values for not listed keys are not touched.
412+
The rationale being that default values are known and clients have the option to send full representations, if necessary.
413+
414+
The following table shows the Node.js runtime's configuration options and their respective default value:
415+
416+
| Flag | Behavior | Default |
417+
|----------------------------------------------|------------------------------------------|---------|
418+
| <Config keyOnly>cds.runtime.patch_as_upsert </Config> | Create resource if it does not yet exist | false |
419+
| <Config keyOnly>cds.runtime.put_as_upsert</Config> | Create resource if it does not yet exist | true |
420+
| <Config keyOnly>cds.runtime.put_as_replace</Config> | Payload is enriched with default values | false |
421+
403422
### Custom Protocol Adapter
404423

405424
Similar to the configuration of the GraphQL Adapter, you can plug in your own protocol.

0 commit comments

Comments
 (0)