What is the JSON API way to update a resource using any params other than the id (PK)?
ie
instead of
PUT posts/:id // SQL: UPDATE posts WHERE id = 1;
something like
PUT posts?userId=1 // SQL: UPDATE posts WHERE userId = 1;
What is the JSON API way to update a resource using any params other than the id (PK)?
ie
instead of
PUT posts/:id // SQL: UPDATE posts WHERE id = 1;
something like
PUT posts?userId=1 // SQL: UPDATE posts WHERE userId = 1;
Bulk updates are not supported by the JSON:API specification itself. It could be supported using extensions. The official Atomic Operations extension supports updating multiple resources at once.
Updating a resource without identifying it by its type
and id
is not even supported by the Atomic Operations extension. Such a use case does not seem to fit well with the core assumptions of the JSON:API specification. Most noticeable that it is about fetching and mutating resources. Applying an operation to all resources identified using filter criteria seems to not fit well into that concept.
Having that said, an extension specifying such operations is possible. Such an extension would need to cover at least three aspects:
Personally I’m not sure if it’s worth it. There are only few use cases in which a client wants to apply an update without knowing all affected resources upfront.