Function: nextSequenceNumber()

nextSequenceNumber(args: { lix: Lix; }): Promise<number>

Returns the next monotonic sequence number, starting at 0.

Async wrapper around nextSequenceNumberSync that runs the computation next to the database engine via the engine router.

  • Available only when lix_deterministic_mode.enabled = true.
  • Persists state across toBlob()/openLix({ blob }).
  • Consider getTimestampSync, uuidV7, or nanoId for typical IDs.

Example

const lix = await openLix({
  keyValues: [{ key: "lix_deterministic_mode", value: { enabled: true } }]
})
const n1 = await nextSequenceNumber({ lix }) // 0
const n2 = await nextSequenceNumber({ lix }) // 1

Parameters

ParameterType
args{ lix: Lix; }
args.lixLix

Returns

Promise<number>