Function: uuidV7()

uuidV7(args: { lix: { call: Call; }; }): Promise<string>

Returns a UUID v7.

In normal mode, returns a standard time-based UUID v7. In deterministic mode, returns UUIDs with a fixed timestamp prefix and sequential counter suffix.

UUID v7 provides better database performance than nanoId due to time-based sorting, but produces longer IDs that are less suitable for URLs.

  • Normal mode: standard UUID v7 with current timestamp.
  • Deterministic mode: fixed prefix "01920000-0000-7000-8800-" + 12-digit hex counter.
  • Counter state shared with nextSequenceNumberSync.
  • Choose UUID v7 for time-sortable database keys; nanoId for URL-friendly short IDs.

Examples

const lix = await openLix();
const id = await uuidV7({ lix }) // "01920000-5432-7654-8abc-def012345678"
const lix = await openLix({
  keyValues: [{ key: "lix_deterministic_mode", value: { enabled: true }, lixcol_version_id: "global" }]
});
await uuidV7({ lix }) // "01920000-0000-7000-8000-000000000000"
await uuidV7({ lix }) // "01920000-0000-7000-8000-000000000001"
await uuidV7({ lix }) // "01920000-0000-7000-8000-000000000002"

Parameters

ParameterType
args{ lix: { call: Call; }; }
args.lix{ call: Call; }
args.lix.callCall

Returns

Promise<string>