Mutations

Patching a document should be done by performing a mutation. Mutations will prevent multiple writes to a document from overwriting previous ones. In most cases, a PATCH request will require an array of mutations in the body.

The following mutation types can be performed:

Mutation

Description

set_field

Sets field to entered value.

remove_field

Removes field value.

array_push

Adds entered value to array.

array_remove_value

Removes entered value from array, if value exists.

A mutation object consists of the following fields:

Property

Type

Contract

Description

action

string

required

Type of mutation, as described above.

field

string

required

Field that will be mutated. A nested property can be accessed by dots (.).

value

any

required *

The value of the mutation.

* depending on mutation type

The body of a mutation request (e.g. PATCH request) should always consists of an array of mutations. Even if it's just a single mutation.

An example of what the request's body should look like:

[{
  "action": "set_field",
  "field": "name",
  "value": "New name"
}, {
  "action": "remove_field",
  "field": "notes"
}]

Last updated

Was this helpful?