Drizzle ServiceDrizzle Service

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

PropTypeDefault
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

PropTypeDefault
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

PropTypeDefault
hooks?
ServiceHooks<T>
-
ids
IdType<T, TOpts>[]
-

Returns

Returns a promise that resolves to a result object:

PropTypeDefault
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

PropTypeDefault
hooks?
ServiceHooks<T>
-
ids
IdType<T, TOpts>[]
-

Returns

Returns a promise that resolves to a result object:

PropTypeDefault
message?
string
-
success
boolean
-

Behavior

Always performs permanent deletion regardless of soft delete configuration.

Type Definitions

Handler

PropTypeDefault
[1]
T | null
-
[0]
Error | null
-

ServiceHooks

PropTypeDefault
onError?
(error: Error) => Promise<void>
-
afterAction?
(data: T['$inferSelect']) => Promise<void>
-
beforeAction?
(data: T['$inferSelect']) => Promise<void>
-

IdType

PropTypeDefault
type?
string | number | bigint
-