Skip to main content

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-in User 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

// Get all records the current user has permissions to view
const myRecords = await base44.entities.MyEntity.list();

Indexable

[entityName: string]: EntityHandler Access any entity by name. Use this to access entities defined in the app.

Example

base44.entities.MyEntity
base44.entities.AnotherEntity

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(sort?, limit?, skip?, fields?): Promise<any>
Lists records with optional pagination and sorting. Retrieves all records of this type with support for sorting, pagination, and field selection.

Parameters

sort
string
Sort parameter, such as '-created_date' for descending. Defaults to '-created_date'.
limit
number
Maximum number of results to return. Defaults to 50.
skip
number
Number of results to skip for pagination. Defaults to 0.
fields
string[]
Array of field names to include in the response. Defaults to all fields.

Returns

Promise<any> Promise resolving to an array of records.

Examples

const records = await base44.entities.MyEntity.list();

filter()

filter(query, sort?, limit?, skip?, fields?): Promise<any>
Filters records based on a query. Retrieves records that match specific criteria with support for sorting, pagination, and field selection.

Parameters

query
Record<string, any>
required
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
string
Sort parameter, such as '-created_date' for descending. Defaults to '-created_date'.
limit
number
Maximum number of results to return. Defaults to 50.
skip
number
Number of results to skip for pagination. Defaults to 0.
fields
string[]
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

const activeRecords = await base44.entities.MyEntity.filter({
  status: 'active'
});

get()

get(id): Promise<any>
Gets a single record by ID. Retrieves a specific record using its unique identifier.

Parameters

id
string
required
The unique identifier of the record.

Returns

Promise<any> Promise resolving to the record.

Example

const record = await base44.entities.MyEntity.get('entity-123');
console.log(record.name);

create()

create(data): Promise<any>
Creates a new record. Creates a new record with the provided data.

Parameters

data
Record<string, any>
required
Object containing the record data.

Returns

Promise<any> Promise resolving to the created record.

Example

const newRecord = await base44.entities.MyEntity.create({
  name: 'My Item',
  status: 'active',
  priority: 'high'
});
console.log('Created record with ID:', newRecord.id);

update()

update(id, data): Promise<any>
Updates an existing record. Updates a record by ID with the provided data. Only the fields included in the data object will be updated.

Parameters

id
string
required
The unique identifier of the record to update.
data
Record<string, any>
required
Object containing the fields to update.

Returns

Promise<any> Promise resolving to the updated record.

Examples

const updated = await base44.entities.MyEntity.update('entity-123', {
  status: 'completed'
});

delete()

delete(id): Promise<any>
Deletes a single record by ID. Permanently removes a record from the database.

Parameters

id
string
required
The unique identifier of the record to delete.

Returns

Promise<any> Promise resolving to the deletion result.

Example

const result = await base44.entities.MyEntity.delete('entity-123');
console.log('Deleted:', result);

deleteMany()

deleteMany(query): Promise<any>
Deletes multiple records matching a query. Permanently removes all records that match the provided query.

Parameters

query
Record<string, any>
required
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

const result = await base44.entities.MyEntity.deleteMany({
  status: 'completed',
  priority: 'low'
});
console.log('Deleted:', result);

bulkCreate()

bulkCreate(data): Promise<any>
Creates multiple records in a single request. Efficiently creates multiple records at once. This is faster than creating them individually.

Parameters

data
Record<string, any>[]
required
Array of record data objects.

Returns

Promise<any> Promise resolving to an array of created records.

Example

const result = await base44.entities.MyEntity.bulkCreate([
  { name: 'Item 1', status: 'active' },
  { name: 'Item 2', status: 'active' },
  { name: 'Item 3', status: 'completed' }
]);

importEntities()

importEntities(file): Promise<any>
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.

Parameters

file
File
required
File object to import.

Returns

Promise<any> Promise resolving to the import result.

Example

const handleFileImport = async (event: React.ChangeEvent<HTMLInputElement>) => {
  const file = event.target.files?.[0];
  if (file) {
    const result = await base44.entities.MyEntity.importEntities(file);
    console.log(`Imported ${result.count} records`);
  }
};