Remote / foldkit-remote-drizzle

ParentLock

interface · packages/remote-drizzle/src/parentLock.ts:27

interface ParentLock<Field extends string = string> {
  readonly table: PgTable
  readonly id: PgColumn
  readonly by: ReadonlyArray<Field>
  readonly onWrite?: (context: {
    readonly parentIds: ReadonlyArray<string>
    readonly tx: ParentLockTransaction
  }) => PromiseLike<void> | void
}

Options for locking parent rows on Postgres during child writes.

Members

ParentLock.table

property · packages/remote-drizzle/src/parentLock.ts:29

readonly table: PgTable

The Postgres parent table whose rows are locked with SELECT ... FOR UPDATE.

ParentLock.id

property · packages/remote-drizzle/src/parentLock.ts:31

readonly id: PgColumn

The parent table's primary key column.

ParentLock.by

property · packages/remote-drizzle/src/parentLock.ts:33

readonly by: ReadonlyArray<Field>

Foreign-key or link field names on the child entity that identify parent row ids.

ParentLock.onWrite

property · packages/remote-drizzle/src/parentLock.ts:38

readonly onWrite?: (context: {
  readonly parentIds: ReadonlyArray<string>
  readonly tx: ParentLockTransaction
}) => PromiseLike<void> | void

Optional hook run inside the same transaction after locking the parent rows and writing the child, e.g. to update a stored aggregate total on the parent.