Skip to main content
This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the developer documentation.

Entities Module

CRUD operations on data models. Access via base44.entities.EntityName.method().

Contents

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-generated id). 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

Oversize records: fields over 10 KB are slimmed for transport on a broadcast — the SDK logs a console error naming the affected record and tells you to call 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-in User entity with special rules:
  • Regular users can only read/update their own record
  • Cannot create users via entities.create() - use auth.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.
  1. Authentication level: anonymous, authenticated, or service role
  2. RLS rules: Control which records (rows) users can create/read/update/delete
  3. FLS rules: Control which fields users can read/write within accessible records
Operations succeed or fail based on these rules - no partial results. RLS and FLS are configured in entity schema files (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 of EntityTypeRegistry from your project. For how to run it, use the base44-cli skill.

EntityHandler

EntitiesModule