Action Spec
Define low-level database operations like insert, update, delete, and select in a consistent format.
Action Spec describe direct, low-level database operations—insert, update, delete, and select. They are the foundation for any server-side data manipulation and power all backend logic within Locospec.
They are typically used behind the scenes by features like Mutators and Views but can also be triggered manually when fine-grained control is needed.
✨ Supported Actions
| Type | Purpose |
|---|---|
insert | Create one or more records |
update | Modify existing records |
delete | Remove (or soft delete) records |
select | Fetch and filter records |
📥 insert
Inserts one or more records into a model’s table.
Required Fields
| Field | Type | Description |
|---|---|---|
type | string | Must be "insert" |
modelName | string | Target model name |
data | array | Array of records to insert |
ℹ️ Supports multiple inserts in one operation.
✏️ update
Updates one or more records matching the given filters.
Required Fields
| Field | Type | Description |
|---|---|---|
type | string | Must be "update" |
modelName | string | Target model name |
filters | object | Conditions to match records |
data | object | Key-value pairs to update |
🗑 delete
Deletes (or soft-deletes) records based on filters.
Required Fields
| Field | Type | Description |
|---|---|---|
type | string | Must be "delete" |
modelName | string | Target model name |
filters | object | Conditions to match records |
softDelete | boolean | If true, marks the record as deleted |
deleteColumn | string | Column used for soft delete timestamp |
📊 select
Retrieves data from the database with filters, scopes, sorts, and pagination.
Required Fields
| Field | Type | Description |
|---|---|---|
type | string | Must be "select" |
modelName | string | The model to query from |
🔍 Filter Format
Actions like select, update, and delete support all three filter formats:
- Filter Group
- Array of Conditions
- Key-Value Object
See the Filter Spec for full reference.
📎 Specs References
- 👉
insert.json - 👉
update.json - 👉
delete.json - 👉
select.json