Writing data
Creating and changing objects: create, PUT (replace) and PATCH (change), the null trap, default values, validation, and what happens with concurrent changes.
Topics in this subject area
- 1.Creating an object
What happens step by step with
POST /create: system fields, default values, hooks, validation, saving, reading back. - 2.Replacing with PUT
PUT describes the complete target state. This page explains what happens to missing fields, references and lists, and where the ID comes from.
- 3.Changing with PATCH
PATCH only changes what you name. This page explains the three states of every field (missing, null, value) for simple fields, references and lists.
- 4.PUT or PATCH? The null trap
Which verb for what, and why a form object with empty fields clears everything with PATCH.
- 5.Default values
When a field automatically gets a value on create, which kinds of defaults exist, and what happens to an unusable default.
- 6.Validation
Which rules are attached to fields, when they are checked, that all violations come collected in one 422, and what the path of a nested error looks like.
- 7.Concurrent changes
There is no
save, and normal models have no optimistic locking: the last change wins. Only file models detect a conflict.