API Reference
Complete API reference for all bulk operations including method signatures, parameters, and return types
bulkCreate()
Create multiple records efficiently in a single database transaction.
bulkCreate(
data: T['$inferInsert'][],
hooks?: ServiceHooks<T>
): Handler<T['$inferSelect'][]>
Parameters
Prop | Type | Default |
---|---|---|
hooks? | ServiceHooks<T> | - |
data | T['$inferInsert'][] | - |
Returns
Returns a Handler<T['$inferSelect'][]>
which is a promise that resolves to:
[null, records[]]
- Success case with array of created records[error, null]
- Error case with detailed error information
bulkUpdate()
Update multiple records with individual change sets in a single transaction.
bulkUpdate(
data: Array<{
id: IdType<T, TOpts>;
changes: Partial<Omit<T['$inferInsert'], 'createdAt' | 'id'>>;
}>,
hooks?: ServiceHooks<T>
): Handler<T['$inferSelect'][]>
Parameters
Prop | Type | Default |
---|---|---|
hooks? | ServiceHooks<T> | - |
data | Array<{ id: IdType<T, TOpts>; changes: Partial<Omit<T['$inferInsert'], 'createdAt' | 'id'>>; }> | - |
Returns
Returns a Handler<T['$inferSelect'][]>
which is a promise that resolves to:
[null, records[]]
- Success case with array of updated records[error, null]
- Error case with detailed error information
bulkDelete()
Delete multiple records by their primary keys, respecting soft delete configuration.
bulkDelete(
ids: IdType<T, TOpts>[],
hooks?: ServiceHooks<T>
): Promise<{ readonly success: boolean; readonly message?: string }>
Parameters
Prop | Type | Default |
---|---|---|
hooks? | ServiceHooks<T> | - |
ids | IdType<T, TOpts>[] | - |
Returns
Returns a promise that resolves to a result object:
Prop | Type | Default |
---|---|---|
message? | string | - |
success | boolean | - |
Behavior
- With Soft Delete: Updates the configured soft delete field for all specified records
- Without Soft Delete: Permanently removes all specified records from the database
bulkHardDelete()
Permanently delete multiple records from the database, bypassing soft delete configuration.
bulkHardDelete(
ids: IdType<T, TOpts>[],
hooks?: ServiceHooks<T>
): Promise<{ readonly success: boolean; readonly message?: string }>
Parameters
Prop | Type | Default |
---|---|---|
hooks? | ServiceHooks<T> | - |
ids | IdType<T, TOpts>[] | - |
Returns
Returns a promise that resolves to a result object:
Prop | Type | Default |
---|---|---|
message? | string | - |
success | boolean | - |
Behavior
Always performs permanent deletion regardless of soft delete configuration.
Type Definitions
Handler
Prop | Type | Default |
---|---|---|
[1] | T | null | - |
[0] | Error | null | - |
ServiceHooks
Prop | Type | Default |
---|---|---|
onError? | (error: Error) => Promise<void> | - |
afterAction? | (data: T['$inferSelect']) => Promise<void> | - |
beforeAction? | (data: T['$inferSelect']) => Promise<void> | - |
IdType
Prop | Type | Default |
---|---|---|
type? | string | number | bigint | - |