Reputation: 472
I am using application/merge-patch+json
as my content type to edit a resource via HTTP PATCH method. I got my data stored in an RDBMS.
The merge patch spec clearly states that when a key is set to a null
value, it should be deleted from the resource.
This is impossible for me to do however, as I cannot simply delete columns in my DB for certain rows - the values I 'delete' are simply set to null
, which goes against the spec.
I thought of two options:
null
, keeping them in the resourceIs there some other way?
Upvotes: 1
Views: 2104
Reputation: 340
The RFC doesn't define how you store your data, it's only about JSON. API/Domain Models should be separated from Entity Layer / DB. How you map between these two, is up to you.
Upvotes: 1
Reputation: 5770
A DELETE
on an API resource doesn't have to be actually deleting the resource in the DB - it could be a soft delete for that matter (which is what you're doing, in fact).
As long as it's properly represented as deleted by the API (e.g. you can omit displaying null values - I think JSON does that for you by default), it can be argued that you're respecting the spec.
Upvotes: 2