Entities Module
CRUD operations on data models. Access viabase44.entities.EntityName.method().
Contents
- Methods
- Query Operators
- Examples (Create, Bulk Create, List, Filter, Get, Update, Delete, Subscribe)
- Cursor Pagination
- Count and Aggregate
- Upsert
- User Entity
- Service Role Access
- Permissions
Methods
Note: The legacy(sort, limit, skip, fields) form of list()/filter() accepts up to 5,000 items per request. The cursor-based form (EntityListOptions) also caps at 5,000 per page but defaults to 100; the distinct-values form (EntityDistinctOptions) caps at 1,000 per page, defaulting to 100.
Query Operators
filter(), count(), deleteMany(), updateMany()’s query argument, and aggregate()’s query field all accept an EntityFilterQuery<T> — a MongoDB-style query object:
A plain array as a field’s value is shorthand for “any of”:
{ external_id: ['item-1', 'item-2'] }. null is a valid exact-match value.
Examples
Create
Bulk Create
List with Pagination
Filter
Get by ID
Update
Delete
delete() and deleteMany() move records to the entity’s trash — they’re restorable via Recently deleted in the Data tab (or the Restore/Permanently delete API endpoints), not a permanent delete. deleteMany() isn’t a transaction: if the call fails partway, records already deleted stay deleted.
Update Many (MongoDB-style)
Supported update operators:$set, $rename, $unset, $inc, $mul, $min, $max, $currentDate, $addToSet, $push, $pull (each field may appear in only one operator per call). Not a transaction — each matching record is updated on its own. Results are batched in groups of up to 500; when result.has_more is true, call updateMany again with the same query (which should exclude already-updated records) to process the next batch.
Bulk Update (by ID)
Cursor Pagination
list() and filter() also accept a single options object for cursor-based paging, preferred over the legacy (sort, limit, skip, fields) form for loops over large result sets. Pass distinct instead of fields to page through a field’s distinct values instead of records.
Count and Aggregate
Upsert
Creates or updates by a natural key (not an auto-generatedid). Up to 500 records per call; last write wins for duplicate keys within the same call; not a transaction.
Import from File
Subscribe to Realtime Updates
entities.<Name>.get(id) to fetch the full record instead of rendering the slimmed payload. This doesn’t apply to delete events.
Event structure:
User Entity
Every app has a built-inUser entity with special rules:
- Regular users can only read/update their own record
- Cannot create users via
entities.create()- useauth.register()instead - Service role can read and update any user, and remove any user except the app owner. A removed user moves to Recently deleted for 30 days, where an app editor can restore them, before being deleted permanently.
Service Role Access
For admin-level operations (bypass user permissions):Permissions (RLS & FLS)
Data access is controlled by Row Level Security (RLS) and Field Level Security (FLS) rules defined in entity schemas.- Authentication level: anonymous, authenticated, or service role
- RLS rules: Control which records (rows) users can create/read/update/delete
- FLS rules: Control which fields users can read/write within accessible records
base44/entities/*.jsonc). See entities-create.md for configuration details.
Note: asServiceRole bypasses RLS and FLS entirely. The client reads and writes any record in any entity without needing a matching admin rule. Use it for trusted backend logic only, and enforce your own access checks when the function needs them.
Type Definitions
RealtimeEvent
Result Types
Query, Pagination, and Aggregation Types
SortField and Server Fields
Type Registry (for typed entities)
How to get typed entities: The Base44 CLI can generate entity interfaces and an augmentation ofEntityTypeRegistry from your project. For how to run it, use the base44-cli skill.