The write methods on aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fajarnugraha37/drizzle-castor/llms.txt
Use this file to discover all available pages before exploring further.
Repository instance handle all insertion and mutation operations against the underlying table. Every method runs through the RBAC middleware before reaching Drizzle ORM, so the profile argument is used to enforce allowedSets and allowedActions policies. The UpdateSet type used by the update methods supports dot-notation paths, which means you can perform partial updates on individual JSON column properties without overwriting the entire column value.
createOne
Inserts a single record and returns the full created entity, including any server-generated defaults such as primary keys and timestamps. SignatureParameters
The insert payload inferred from the Drizzle table definition. The shape is identical to what you would pass to
db.insert(table).values(...) directly. Required columns must be provided; optional columns may be omitted.The RBAC profile (or profiles) to evaluate. Fields listed in
allowedSets for the active profile are the only fields permitted to be written. Any field not in allowedSets is silently stripped from the payload before the insert executes. Defaults to "default" when omitted.Return value
The complete entity as it exists in the database after the insert, including generated values.
Example
createMany
Inserts multiple records in a single operation and returns all created entities as an array. The order of the returned array matches the order of the input array. SignatureParameters
An array of insert payloads. Each element follows the same rules as the
data parameter in createOne. An empty array is a no-op and returns an empty array.RBAC profile(s) to evaluate. The
allowedSets policy is applied to every element in the array.Return value
An array of fully-hydrated entities in insertion order.
Example
updateOne
Updates a single record identified by its primary key value and returns the updated entity. Returnsnull if no record with the given id exists among the currently active (non-deleted) rows.
Signature
Parameters
The primary key value of the record to update. The method automatically identifies the correct primary key column from the table definition.
The fields to update.
UpdateSet is a mapped type over all valid dot-notation paths of the insert type, so top-level columns and nested JSON paths are both supported. Only the keys present in the object are written; all other fields are left unchanged.RBAC profile(s) to evaluate. Fields not in
allowedSets are stripped before the SQL UPDATE is built.Return value
The fully-hydrated entity after the update, or
null if no active record with the given id was found.Example
updateMany
Updates all active records matching a filter condition and returns every updated entity as an array. This is useful for bulk operations such as disabling features for a segment of users. SignatureParameters
The WHERE condition expressed as a structured filter object. Supports the same operator keys (
$eq, $lt, $or, $and, etc.) and dot-notation paths as the filter field in read methods. Only active (non-soft-deleted) records are considered.The fields to update on every matched record. Same dot-notation rules as
updateOne.RBAC profile(s) to evaluate. Both
allowedFilters and allowedSets policies apply.Return value
An array of all updated entities in their post-update state. Returns an empty array if no records matched the filter.
Example
Factory helpers
These methods are pure type-narrowing utilities. They perform no database operation and exist solely to give TypeScript the information it needs to infer the correct types when building insert or update objects in isolation.defineInsertValue
createOne / createMany call.
defineUpdateSet
UpdateSet object. Use this to define reusable update presets with full autocomplete on the dot-notation paths.