Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.
Author
Dan Ribbens headshot
Dan Ribbens
Published On

Launch Week Day 3 - Bulk Operations

Author
Dan Ribbens headshot
Dan Ribbens
Published On
Bulk Operations
Bulk Operations
The long awaited new feature lets editors edit, delete and publish many documents of a collection all at once.

We’ve improved the editor experience by adding selection in the collection list view and new controls to Edit, Delete, and if drafts are enabled, Publish, and Unpublish. We also added API endpoints to handle the changes and also extended the local API for programmatic access. The new features are available in v1.6.24 and later.

Delete, Publish, Unpublish Many

The workflow for these are all much the same, select a bunch of documents and go for it. You’ll get a prompt to make sure you are happy with your life choices before submitting. The changes are all handled in one request. After submitting, the UI shows the number of updated documents. If there are any errors that occur due to validation or any faults in a hook on the backend, the number of documents that didn’t get updated due to error is also shown. The results are more detailed in the HTTP response or local API for your apps to deal with.

Edit Many

The editing experience for multiple documents in a collection allows the editor to choose which fields to update. You can access all fields within a nested structure with the field selector and input your changes before saving. Fields that are hidden, unique or read-only are not available, and you can also configure the admin.disableBulkEdit option to remove certain fields.



When drafts are enabled for a collection, you also have the choice to publish or save as draft. That gives you three ways to submit:

  • Save updates the published document or most recent draft document in place without changing any statuses.
  • Publish takes your changes, adds it to the most recent document version and publishes the results.
  • Draft saves a draft version of your changes along with the most recent version of each document and does not affect what you currently have published.

Filter and Select All

Instead of selecting individual rows in the list, an editor can select all documents in the list. The select-all option can be used with the existing search and filter options to only include all documents matching certain criteria. With this, the bulk edit, publish, unpublish and delete workflows will use the query to perform the operation against all the matching items.

API Changes

The new functionality extends to the backend and local API as well.

There are new REST endpoints for collections to allow for bulk delete and updates:

  • PATCH /api/pages
  • DELETE /api/pages

Each endpoint takes a query in the same form as a GET request would to make our changes against.

The local APIs have also been extended to take either an id or where query.

1
const result = await payload.update({
2
collection: 'posts',
3
where: {
4
id: { in: ids },
5
},
6
data: {
7
title: 'Doc Title',
8
},
9
});
10
11
// result:
12
// {
13
// docs: [{...}]
14
// errors: []
15
// }

Try it out

Update your own Payload project or head on over to the public demo at demo.payloadcms.com and give it a shot.