docs
docs copied to clipboard
Improve updating multiple items api reference
The "Update Multiple Items" section in the API reference is missing 2 supported methods of doing multiple updates.
On this page https://directus.io/docs/api/items#update-multiple-items we are currently documenting the "update many by keys" approach, here you provide a list of keys and one single object to update all keys with.
PATCH /items/:collection
{
"keys": [1,2,3,4],
"data": {
"status": "published"
}
}
We also support the following approaches:
- "update many by query" similar to the one above but instead of providing a list of ID's you provide a query to filter items to be updated with a single object.
PATCH /items/:collection
{
"query": {
"filter": {
"status": { "_eq": "draft" },
},
},
"data": {
"status": "published"
}
}
- "batch updating" this approach allows the sending of a list of items to updated based on ID so each individual item can update different properties.
PATCH /items/:collection
[
{
"id": 1,
"status": "published"
},
{
"id": 2,
"status": "archived"
},
{
"id": 3,
"title": "something"
},
]