Entities module for managing app data. This module provides dynamic access to all entities in the app. Each entity gets a handler with full CRUD operations and additional utility methods. Entities are accessed dynamically using the pattern:
base44.entities.EntityName.method()
This module is available to use with a client in all three authentication modes:
- Anonymous or User authentication (
base44.entities): Access is scoped to the current user’s permissions. Anonymous users can only access public entities, while authenticated users can access entities they have permission to view or modify. - Service role authentication (
base44.asServiceRole.entities): Operations have elevated admin-level permissions. Can access all entities that the app’s admin role has access to.
Built-in User Entity
Every app includes a built-inUser entity that stores user account information. This entity has special security rules that can’t be changed.
Regular users can only read and update their own user record. With service role authentication, you can read, update, and delete any user. You can’t create users using the entities module. Instead, use the functions of the auth module to invite or register new users.
Examples
Indexable
[entityName: string]: EntityHandler
Access any entity by name.
Use this to access entities defined in the app.
Example
EntityHandler
Entity handler providing CRUD operations for a specific entity type. Each entity in the app gets a handler with these methods for managing data.
Methods
list()
list(Lists records with optional pagination and sorting. Retrieves all records of this type with support for sorting, pagination, and field selection.sort?,limit?,skip?,fields?):Promise<any>
Parameters
Properties
Properties
Sort parameter, such as
'-created_date' for descending. Defaults to '-created_date'.Maximum number of results to return. Defaults to
50.Number of results to skip for pagination. Defaults to
0.Array of field names to include in the response. Defaults to all fields.
Returns
Promise<any>
Promise resolving to an array of records.
Examples
filter()
filter(Filters records based on a query. Retrieves records that match specific criteria with support for sorting, pagination, and field selection.query,sort?,limit?,skip?,fields?):Promise<any>
Parameters
Properties
Properties
Query object with field-value pairs. Each key should be a field name
from your entity schema, and each value is the criteria to match. Records matching all
specified criteria are returned. Field names are case-sensitive.
Sort parameter, such as
'-created_date' for descending. Defaults to '-created_date'.Maximum number of results to return. Defaults to
50.Number of results to skip for pagination. Defaults to
0.Array of field names to include in the response. Defaults to all fields.
Returns
Promise<any>
Promise resolving to an array of filtered records.
Examples
get()
get(Gets a single record by ID. Retrieves a specific record using its unique identifier.id):Promise<any>
Parameters
The unique identifier of the record.
Returns
Promise<any>
Promise resolving to the record.
Example
create()
create(Creates a new record. Creates a new record with the provided data.data):Promise<any>
Parameters
Object containing the record data.
Returns
Promise<any>
Promise resolving to the created record.
Example
update()
update(Updates an existing record. Updates a record by ID with the provided data. Only the fields included in the data object will be updated.id,data):Promise<any>
Parameters
Properties
Properties
Returns
Promise<any>
Promise resolving to the updated record.
Examples
delete()
delete(Deletes a single record by ID. Permanently removes a record from the database.id):Promise<any>
Parameters
The unique identifier of the record to delete.
Returns
Promise<any>
Promise resolving to the deletion result.
Example
deleteMany()
deleteMany(Deletes multiple records matching a query. Permanently removes all records that match the provided query.query):Promise<any>
Parameters
Query object with field-value pairs. Each key should be a field name
from your entity schema, and each value is the criteria to match. Records matching all
specified criteria will be deleted. Field names are case-sensitive.
Returns
Promise<any>
Promise resolving to the deletion result.
Example
bulkCreate()
bulkCreate(Creates multiple records in a single request. Efficiently creates multiple records at once. This is faster than creating them individually.data):Promise<any>
Parameters
Array of record data objects.
Returns
Promise<any>
Promise resolving to an array of created records.
Example
importEntities()
importEntities(Imports records from a file. Imports records from a file, typically CSV or similar format. The file format should match your entity structure. Requires a browser environment and can’t be used in the backend.file):Promise<any>
Parameters
File object to import.
Returns
Promise<any>
Promise resolving to the import result.

