What are collections?
A collection in PocketBase is similar to a table in a traditional database. It defines:- The fields (columns) that records will have
- Validation rules for each field
- API rules for accessing and modifying records
- Type-specific configurations
Collection types
PocketBase supports three types of collections, each designed for different use cases:Base collections
Standard collections for storing any type of data
Auth collections
Special collections with built-in authentication features
View collections
Read-only collections based on SQL queries
Core properties
All collections share these core properties:Name and identity
/api/collections/{name}/records), while the ID is a stable identifier that doesn’t change even if you rename the collection.
API rules
Collections have five API rules that control access to records:- List rule
- View rule
- Create rule
- Update rule
- Delete rule
Controls who can fetch multiple records from the collection.
Rules use PocketBase’s filter syntax. Set to
nil to deny all access, "" to allow all, or a filter expression like "@request.auth.id != ''" for conditional access.Fields
TheFields property contains a list of all fields in the collection:
Indexes
You can define database indexes to improve query performance:Working with collections
Creating a new collection
- Factory functions
- Generic factory
Use the factory functions to create collections with proper defaults:
Adding fields
After creating a collection, add fields to define its structure:Saving a collection
Use the app’s DAO methods to persist collections:When you save a collection, PocketBase automatically creates or updates the corresponding database table and applies any schema changes.
System collections
PocketBase includes several system collections that start with an underscore:_collections- Stores collection definitions_superusers- Admin users_externalAuths- OAuth2 authentication data_mfas- Multi-factor authentication data_otps- One-time passwords
Next steps
Explore the different collection types to understand which one fits your needs:Base collections
Learn about standard collections
Auth collections
Add user authentication
Fields reference
Explore all field types