API reference / @evolu/common / Type / createId
Function: createId()
function createId<B>(
deps,
): [B] extends [never] ? string & Brand<"Id"> : string & Brand<"Id"> & Brand<B>;
Defined in: packages/common/src/Type.ts:1644
Creates a random Id. This is the recommended default.
Use createIdFromString for deterministic mapping of external IDs or createIdAsUuidv7 when you accept timestamp leakage for index locality.
Example
const id = createId(deps);
const todoId = createId<"Todo">(deps);
Type Parameters
| Type Parameter | Default type |
|---|---|
B extends string | never |
Parameters
| Parameter | Type |
|---|---|
deps | RandomBytesDep |
Returns
[B] extends [never] ? string & Brand<"Id"> : string & Brand<"Id"> & Brand<B>