Data Modelling
Entities
An entity is a table in your database. Create as many entities as your application needs.
Go to Settings → Data Model and click + New Entity. Give it a name in snake_case (e.g. blog_posts, customers, orders).
Every entity automatically gets:
- An
idfield (auto-incrementing integer, primary key) created_atandupdated_attimestamps (managed automatically)- A full REST API (list, get, create, update, delete)
Field types
When adding a field, choose a storage type that determines how the data is stored in the database.
| Type | Stored as | Use for |
|---|---|---|
varchar |
VARCHAR(255) | Short text — names, slugs, status values, email addresses |
text |
TEXT | Long text — descriptions, body content, notes |
integer |
INTEGER | Whole numbers — quantities, counts, ages |
float |
FLOAT | Decimal numbers — prices, ratings, percentages |
boolean |
BOOLEAN | True / false flags — active, published, in_stock |
date |
DATE | Calendar dates (no time) |
timestamp |
TIMESTAMP | Date and time |
jsonb |
JSONB | Arbitrary JSON structures — metadata, config objects |
geo |
GEOMETRY | Geographic coordinates (latitude / longitude) |
file |
FK to files | An uploaded file — image, document, video |
| Foreign key | INT (FK) | A link to a record in another entity |
varchar — multi-select options
A varchar field can be configured as a multi-select with a fixed set of allowed values. Define the options when creating the field. Values are stored as a varchar[] array.
Display types
When adding a field, you also choose how it renders in the dashboard UI. The display type is separate from the storage type and does not affect the API.
| Display type | Best for |
|---|---|
| Input (default) | Standard single-line text |
| Textarea | Multi-line plain text |
| Rich text | Long-form content with formatting (supports Markdown) |
| Date picker | Dates and date-times |
| JSON editor | Structured JSON with syntax highlighting |
| Map | Geographic fields — renders a map picker |
| File upload | Files — supports multiple files, public/private |
Field options
When creating or editing a field, you can set:
| Option | Description |
|---|---|
| Required | The field must have a value when a record is created |
| Unique | No two records can have the same value for this field |
| Immutable | The field cannot be changed after the record is created |
| Indexed | Adds a database index — improves query performance on large datasets |
| Name field | This field is used as the human-readable display name for the record in the dashboard |
Relationships (foreign keys)
Link entities together by adding a Foreign key field. Choose:
- Entity — which entity this field points to (e.g.
categories) - Display — which field from the related entity to show in the dashboard
When creating a record via the API, pass the ID of the related record:
POST /entities/products/items
{
"name": "Wireless Headphones",
"price": 79.99,
"category": 3
}
The category field stores the integer ID of the related category record.
Filtering by relationship
GET /entities/products/items?filter[category]=3
Row-level security (RLS)
When creating an entity, you can enable Row-Level Security. This locks each record to the user who created it — other users cannot read or modify records they do not own, regardless of role permissions.
Enable RLS on the entity settings page, or when creating via the CLI:
anythink entities create orders --rls
Modifying entities
You can add new fields to existing entities at any time. The new field is added to the database immediately and all existing records get a null value for it.
Deleting a field permanently removes it and all its data. There is no undo.
The live API
After saving any change to your data model, the API updates immediately. Open the API Documentation link in your dashboard to see the current endpoints and try them live.