Overview
Mutations provide a type-safe API for modifying data. All mutations include:- Three-stage validation (schema → types → constraints)
- Automatic safety guards (e.g., UPDATE/DELETE requires WHERE clause)
- Rich error messages with suggestions
- Debug mode support
Insert
Insert()
Starts a new INSERT operation.string
required
Entity name to insert into (e.g., “User”, “Post”)
Set()
Adds a field value to insert.string
required
Field name
interface{}
required
Value to insert (string, int, float64, bool, time.Time, uuid, etc.)
Execute()
Validates and executes the INSERT operation.*InsertResult
Result containing the inserted record
interface{}
Primary key of the inserted record
map[string]interface{}
Full inserted record (from RETURNING *)
int
Number of rows inserted (always 1)
Update
Update()
Starts a new UPDATE operation.string
required
Entity name to update (e.g., “User”, “Post”)
Set()
Adds a field to update.string
required
Field name to update
interface{}
required
New value
Filter()
Adds a WHERE condition (required for safety).string
required
Field name to filter on
string
required
Comparison operator:
"eq", "neq", "gt", "gte", "lt", "lte", "like"interface{}
required
Value to compare against
Execute()
Validates and executes the UPDATE operation.*UpdateResult
Result containing updated records
[]map[string]interface{}
All updated records (from RETURNING *)
int
Number of rows updated
Delete
Delete()
Starts a new DELETE operation.string
required
Entity name to delete from (e.g., “User”, “Post”)
Filter()
Adds a WHERE condition (required for safety).string
required
Field name to filter on
string
required
Comparison operator
interface{}
required
Value to compare against
Execute()
Validates and executes the DELETE operation.*DeleteResult
Result containing number of deleted rows
int
Number of rows deleted
Debug Mode
Debug()
Enables SQL debug output for the mutation.Validation
All mutations go through a three-stage validation pipeline:1. Schema Validation
Verifies entity and field names exist in the schema.2. Type Validation
Verifies value types match field definitions.3. Constraint Validation
Verifies database constraints (executed at database level).Complete Examples
Creating Related Records
Conditional Updates
Batch Operations
See Also
- Engine - Initialize and configure the engine
- Query Builder - Query data
- Error Handling - Handle mutation errors