API reference / @evolu/common / Type / id

Function: id()

function id<Table>(table): TableId<Table>;

Defined in: packages/common/src/Type.ts:1599

Creates a branded Id Type for a table's primary key.

The table name becomes an additional brand for type safety.

Example

const TodoId = id("Todo");
// string & Brand<"Id"> & Brand<"Todo">
type TodoId = typeof TodoId.Type;

Type Parameters

Type Parameter
Table extends string

Parameters

ParameterType
tableTable

Returns

TableId<Table>

Was this page helpful?