Sparse updates
When updating a nested collection under a resource, the option sparse can be specified with the value true or false
- "sparse": true => collection elements not specified in the update requests are not modified
- "sparse": false => collection elements not specified in the update requests are deleted
Example: Update an employees work_locations
employee
{ "employees": { "id": "4fc4d621-8037-0133-3e14-025dd6a1bb31", "first_name": "John", "last_name": "Doe", "birth_date": "1976-03-17", "work_locations": [ { "id": "568f021e9537296f45004856", "role": "developer", "work_location_id": "c48ca3b1-97cb-0133-6118-060bcee6eb9d" }, { "id": "568f021e9537296f45004858", "role": "developer", "work_location_id": "e9c39df1-97cb-0133-611c-060bcee6eb9d" } ], "channel_id": "org-abcd", "resource_type": "employees" } }
Sparse update
Sending the following request with the option "sparse": true
{ "employees": { "opts": { "sparse": true }, "work_locations": [ { "role": "software developer", "work_location_id": "c48ca3b1-97cb-0133-6118-060bcee6eb9d" } ] } }
Response
{ "employees": { "id": "4fc4d621-8037-0133-3e14-025dd6a1bb31", "first_name": "John", "last_name": "Doe", "birth_date": "1976-03-17", "work_locations": [ { "id": "568f021e9537296f45004856", "role": "software developer", "work_location_id": "c48ca3b1-97cb-0133-6118-060bcee6eb9d" }, { "id": "568f021e9537296f45004858", "role": "developer", "work_location_id": "e9c39df1-97cb-0133-611c-060bcee6eb9d" } ], "channel_id": "org-abcd", "resource_type": "employees" } }
Non-sparse update
Sending the following request with the option "sparse": false
{ "employees": { "opts": { "sparse": false }, "work_locations": [ { "role": "software developer", "work_location_id": "c48ca3b1-97cb-0133-6118-060bcee6eb9d" } ] } }
Response
{ "employees": { "id": "4fc4d621-8037-0133-3e14-025dd6a1bb31", "first_name": "John", "last_name": "Doe", "birth_date": "1976-03-17", "work_locations": [ { "id": "568f021e9537296f45004856", "role": "software developer", "work_location_id": "c48ca3b1-97cb-0133-6118-060bcee6eb9d" } ], "channel_id": "org-abcd", "resource_type": "employees" } }