Collections
Collections are the building blocks of FastCMS. Learn about Base, Auth, and View collection types.
Collections
FastCMS supports three types of collections, each designed for different use cases.
Collection Types
1. Base Collections
Standard collections for storing any type of data.
Use cases: Products, blog posts, comments, orders, any custom data
Features:
- Define custom schema with any field types
- Full CRUD operations via API
- Access control rules
- Automatic timestamps (
created,updated)
2. Auth Collections
Special collections designed for user authentication. Auth collections automatically include authentication fields and endpoints.
Automatically added fields:
email(unique, indexed)password(hashed with bcrypt)verified(boolean, email verification status)role(string, user role)token_key(string, for session invalidation)
Automatically created endpoints:
POST /api/v1/collections/{name}/auth/registerPOST /api/v1/collections/{name}/auth/loginPOST /api/v1/collections/{name}/auth/refreshPOST /api/v1/collections/{name}/auth/otp/request— request OTP codePOST /api/v1/collections/{name}/auth/otp/verify— verify OTP and get tokensPOST /api/v1/collections/{name}/auth/me/change-passwordPOST /api/v1/collections/{name}/auth/me/request-email-changePOST /api/v1/collections/{name}/auth/me/confirm-email-changeGET /api/v1/collections/{name}/auth/sessions— list active sessionsDELETE /api/v1/collections/{name}/auth/sessions/{session_id}— revoke a session
Custom identity field: By default, auth collections use email as the login identifier. You can change this via the identity_field collection option:
{
"name": "staff",
"type": "auth",
"options": {
"identity_field": "username"
}
}Users then log in with their username value instead of email.
Access control: Auth collections support all five standard rules (list_rule, view_rule, create_rule, update_rule, delete_rule) plus a sixth — manage_rule — which gates privileged user management operations like account unlocking and forced verification. See Access Control for details.
Use cases: Customer accounts, vendor portals, team member access, any user type requiring authentication
3. View Collections
Virtual collections that compute data from other collections. Views do not store data but execute SQL queries to aggregate or join data from existing collections.
Features:
- Define SQL SELECT queries
- Support for JOINs, GROUP BY, ORDER BY
- Configurable caching (TTL in seconds)
- Read-only (no create, update, delete)
Use cases: Sales reports, user statistics, aggregated data, joined data from multiple collections
Admin Dashboard
The collections list shows all collections with their type, field count, and access rules at a glance:
Collections
Manage database collections and schemas
posts
baseFields
8
users
authFields
5
products
baseFields
12
orders
baseFields
9
site_stats
viewFields
4
categories
baseFields
3
Creating Collections
Via Admin Dashboard
- Navigate to
http://localhost:8000/admin/collections - Click "Create Collection"
- Fill in the form: name, type, schema fields
- Click "Create Collection"
Via API
curl -X POST http://localhost:8000/api/v1/collections \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "products",
"type": "base",
"schema": [
{
"name": "title",
"type": "text",
"validation": {"required": true}
},
{
"name": "price",
"type": "number",
"validation": {"required": true}
}
]
}'Collections vs Records
| Concept | Description | API Endpoint |
|---|---|---|
| Collection | The schema/structure (like a table definition) | /api/v1/collections |
| Record | The data entries within a collection (rows) | /api/v1/collections/{name}/records |
Next Steps
- Working with Records — CRUD operations for data
- Field Types — available field types and validation
- Access Control — controlling who can access what