When we use PATCH, we are partially updating a resource. What's the best practice if I want to remove part of the resource?
For example: we have a Person resource:
Person:
{
id: 3,
name: 'test',
companyId: 1,
}
Lets say this person leaves the company and has no job, then the companyId should be set as null
in the DB. When I want to remove the companyId
in Person
via API, shall I set the companyId in the payload as null
as well?
PATCH: /person/3
Person:
{
id: 3,
companyId: null,
}
I used to remove an object by setting it as {}
, or remove an array by setting it as []
, but I am not 100% sure what's the best practice for a primitive property (like the companyId
in this case). Any idea?
Thanks