Get entities with optional filtering and pagination
This method retrieves entities from the API. When called without an ID, it returns a list of entities with optional filtering and pagination. When called with an ID, it returns a specific entity.
Optional query parameters for filtering and pagination
Query parameters interface for API requests
Used to define common query parameters that can be passed to API endpoints for filtering, sorting, and pagination.
Additional custom query parameters
Optionalq?: stringSearch term for text-based filtering
Optionallimit?: numberMaximum number of items to return
Optionaloffset?: numberNumber of items to skip (for offset-based pagination)
Optionaltags?: string[]Array of tags to filter by
Optionalactive?: booleanFilter by active status
Optionalexternal_id?: stringFilter by external ID
Optional specific entity ID to retrieve
Promise resolving to:
- BatchAPIResponse
Get multiple entities with filtering:
const result = await collection.get({
limit: 10,
offset: 0,
q: 'search term',
active: true,
tags: ['tag1', 'tag2']
});
console.log('Items:', result.data);
console.log('Total:', result.paging?.total);
Get entities with optional filtering and pagination
This method retrieves entities from the API. When called without an ID, it returns a list of entities with optional filtering and pagination. When called with an ID, it returns a specific entity.
Optionalparams: QueryParamsOptional query parameters for filtering and pagination
Query parameters interface for API requests
Used to define common query parameters that can be passed to API endpoints for filtering, sorting, and pagination.
Additional custom query parameters
Optionalq?: stringSearch term for text-based filtering
Optionallimit?: numberMaximum number of items to return
Optionaloffset?: numberNumber of items to skip (for offset-based pagination)
Optionaltags?: string[]Array of tags to filter by
Optionalactive?: booleanFilter by active status
Optionalexternal_id?: stringFilter by external ID
Promise resolving to:
- BatchAPIResponse
Get multiple entities with filtering:
const result = await collection.get({
limit: 10,
offset: 0,
q: 'search term',
active: true,
tags: ['tag1', 'tag2']
});
console.log('Items:', result.data);
console.log('Total:', result.paging?.total);
Create a new entity
This method creates a new entity in the system. The entity ID will be automatically generated by the server. The method returns a new model instance initialized with the created entity's data.
Entity data for the new entity (without ID)
Promise resolving to a new model instance
Create a new user:
const newUser = await users.create({
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
active: true
});
console.log('Created user:', newUser.id);
Update an existing entity
This method updates an existing entity in the system. Only the fields provided in the update data will be updated.
The entity ID to update
Partial entity data for the update (only provided fields will be updated)
Optionalparams: QueryParamsOptional query parameters for the request
Promise resolving to the updated model instance
Delete an entity
This method permanently deletes an entity from the system. This action cannot be undone.
The entity ID to delete
Optionalparams: QueryParamsOptional query parameters object. Can include:
force: Force deletion even if entity has dependencies (boolean)Promise that resolves when deletion is successful
Tasks API client for the Mosaia SDK
Provides CRUD operations for managing tasks in the Mosaia platform.