Query presets vs baseListFilter
- Base list filters are developer-defined and hard-coded for specific collections. They’re typically used for features like soft deletes:
- Query presets are dynamic, user-created filters stored in the database. They’re created via the Payload admin UI and can be private, shared globally, or shared with specific users or roles.
Config options of Query presets
- Limit usage of Query presents to certain users: Hardcoded in the config (only admins can create presets).
- Choose whether a preset is private or shared: Dynamic, can be chosen in admin panel when creating a preset.
- Default options (for every CRUD operation): Only me, everyone, specific users
- Custom options (hardcoded in config) that user can select. For example, users with role 'editor' can see or update my present.
Enabling Query Presets
In our example collection config (e.g., companies
), add:
1export const Companies: CollectionConfig = {
7 { name: 'name', type: 'text' },
8 { name: 'description', type: 'textarea' },
9 { name: 'website', type: 'text' },
10 { name: 'logo', type: 'upload', relationTo: 'media' },
11 { name: 'active', type: 'checkbox' },
This enables users to create and manage presets directly in the admin panel.
Creating a Preset
- Open a collection (like
companies
) in the admin panel. - Click the Filters button and add a condition (e.g.,
active equals true
). - Open the Presets menu (three dots) and click Create new.
- Name your preset (e.g., “Only active companies”).
- Choose whether it’s private, shared globally, or shared with specific users.
- Optionally customize visible columns before saving.
Controlling who can use or create presets
You can limit access via payload.config.ts
.
For example:
4 create: ({ req: { user } }) => user?.roles?.includes('admin'),
6 update: ({ req: { user } }) => user?.roles?.includes('admin'),
7 delete: ({ req: { user } }) => user?.roles?.includes('admin'),
This restricts preset creation and management to users with the admin
role.
Advanced sharing options
You can define custom share targets (like all editors) by extending the share config. Example:
5 label: 'Specific Roles',
6 value: 'specificRoles',
13 { label: 'Admin', value: 'admin' },
14 { label: 'Editor', value: 'editor' },
18 access: ({ req: { user } }) => ({
19 'access.read.roles': {
In the UI, users can now choose to share with “All Editors” during preset creation, assuming access conditions are met.
Query presents ultimately gives users real control over their view of the data, while still giving developers full control over access and permissions.