web / lib/collections/datasets/access
lib/collections/datasets/access
Access control logic for the Datasets collection.
Defines read, create, update, and delete permissions based on:
- User role (admin/editor has full access)
- Public/private status of datasets
- Catalog ownership (via denormalized catalogCreatorId)
Since dataset.isPublic=true guarantees catalog.isPublic=true (enforced by hook), we only need to check dataset.isPublic for public access. Private datasets are visible to catalog owners.
Variables
read
constread:Access
Read access: Datasets visible if both dataset AND catalog are public, OR if user owns the catalog. Zero queries - just returns a WHERE clause on indexed fields.
Note: A “public” dataset in a private catalog should NOT be visible to non-owners. The catalog visibility is the top-level gate.
create
constcreate:Access
Create access: Any authenticated user can create datasets. The beforeChange hook validates that users can only create in their own catalogs (admins/editors can create in any catalog).
update
constupdate:Access
Update access: Admins/editors can update all datasets, catalog owners can update their own. Uses WHERE clause on indexed catalogCreatorId field for zero queries.
deleteAccess
constdeleteAccess:Access=isEditorOrAdmin
Delete access: Only admins/editors can delete datasets.
readVersions
constreadVersions:Access=isEditorOrAdmin
ReadVersions access: Only admins and editors can read version history.