PrimaryKeyProperty<TValue extends PrimaryKeyType>(
config?: DatabaseKeyPropertyConfig<TValue>,
):
| Readonly<
{
createGetter: (
value: string,
modelData: TData,
modelInstance: ModelInstance<
Readonly<{ [s: string]: any }>,
object,
object,
>,
) => ValueGetter<string, Readonly<{ [s: string]: any }>, object, object>;
getChoices: () => readonly ChoiceTypes[];
getConfig: () => object;
getConstantValue: () => string | undefined;
getDefaultValue: () => string | undefined;
getPropertyType: () => string;
getValidator: (
valueGetter: ValueGetter<
string,
Readonly<{ [s: string]: any }>,
object,
object,
>,
) => PropertyValidator<Readonly<{ [s: string]: any }>>;
getZod: () => ZodType<string>;
},
>
| Readonly<
{
createGetter: (
value: number,
modelData: TData,
modelInstance: ModelInstance<
Readonly<{ [s: string]: any }>,
object,
object,
>,
) => ValueGetter<number, Readonly<{ [s: string]: any }>, object, object>;
getChoices: () => readonly ChoiceTypes[];
getConfig: () => object;
getConstantValue: () => number | undefined;
getDefaultValue: () => number | undefined;
getPropertyType: () => string;
getValidator: (
valueGetter: ValueGetter<
number,
Readonly<{ [s: string]: any }>,
object,
object,
>,
) => PropertyValidator<Readonly<{ [s: string]: any }>>;
getZod: () => ZodType<number>;
},
>
A property that represents a primary key in a database. By default it is a "uuid" type, but if you want to use an arbitrary string, or an integer type you can set the
dataTypeproperty. Includes an optional primaryKeyGenerator function that can be used to generate a primary key. This can allow primary keys that are generated at runtime, or grabbed from a database.