Collections

Collections are database tables with auto-generated CRUD APIs. Define fields, set permissions, and query data.

#Collections

Collections are the core data model in EmuView. Each collection is a database table backed by Cloudflare D1 (SQLite) with a full CRUD API generated automatically.

You define a collection's fields and types, and EmuView handles table creation, validation, indexing, and API routing. Every collection gets endpoints for listing, creating, reading, updating, and deleting records — with filtering, sorting, pagination, and full-text search built in.

#What you can do

Action How
Define a schema Create a collection with typed fields via the dashboard or POST /api/v1/collections
Insert and query data Use the records API or SDK to perform CRUD operations
Filter and sort Apply field-level filters and sort by any indexed column
Link collections Use relation fields to create foreign key references between collections
Search records Full-text search across text, email, URL, slug, richtext, markdown, and enum fields
Control access Give each role a per-collection row scope (all / own / crew) with row- and column-level security

#Key concepts

Concept What it means
Field type One of 23 data types (text, number, relation, file, and others) that defines how a column stores and validates data
System fields id, created_at, updated_at, created_by, updated_by, deleted_at — added to every collection automatically
Schema version Incremented each time you add fields. Existing fields cannot be removed or renamed (SQLite limitation)
Access Per role, a row scope (none / all / own / crew) plus write — enforced via RBAC and optional crews
Soft delete Records are marked with deleted_at by default. Use ?permanent=true to remove them from the database

#How it fits together

A collection starts with a schema. The schema creates a D1 table and a CRUD API, records flow through that API, relation fields link records across collections, and access control filters every request:

flowchart LR
    Schema["Schema<br>23 field types"] -->|creates| Table[("D1 table")]
    Schema -->|generates| API["Records API<br>/api/v1/collections/:name/records"]
    API --> Records["Records"]
    Records <-->|relation fields| Other["Other collections"]
    AC["Access control<br>roles, row and column rules"] -.->|filters every request| API

Collections connect to other EmuView capabilities:

  • Auth — Access policies reference roles assigned to users
  • Filesfile fields store references to R2-hosted uploads
  • Automation — Flows trigger on record.create, record.update, and record.delete events
  • Real-time — SSE and WebSocket streams broadcast changes to connected clients

#Guides in this section

  • Field types — All 23 field types with storage details and configuration options
  • Filtering records — Query syntax, operators, and filter patterns
  • Relations — Link collections with belongsTo and hasMany relations
  • Search — Full-text search configuration and query syntax
  • Access control — Roles, row-level security, and column-level permissions