Framework
Field<Type, Optional, Custom>
Class: Field<Type, Optional, Custom>
Field builder class with fluent modifiers.
Type Parameters
Constructors
new Field()
new Field<Type, Optional, Custom>(type): Field<Type, Optional, Custom>Parameters
| Parameter | Type |
|---|---|
type | Type |
Returns
Field<Type, Optional, Custom>
Properties
| Property | Modifier | Type |
|---|---|---|
_def | readonly | FieldDef |
_isRelation | readonly | false |
Methods
default()
default(value): thisSet a default value for this field. Can be a static value or a factory function.
Parameters
| Parameter | Type |
|---|---|
value | InferType<Type, Custom> | () => InferType<Type, Custom> |
Returns
this
indexed()
indexed(): thisMark this field as indexed (creates sorted index).
Returns
this
indexedWith()
indexedWith(type): thisMark this field with custom index type(s).
Parameters
| Parameter | Type |
|---|---|
type | string | string[] |
Returns
this
optional()
optional(): Field<Type, true, Custom>Mark this field as optional.
Returns
Field<Type, true, Custom>
primaryKey()
primaryKey(): thisMark this field as the primary key.
Returns
this
unique()
unique(): thisMark this field as unique (creates unique constraint).
Returns
this
values()
values<T>(values): thisSet allowed enum values (for enum type).
Type Parameters
| Type Parameter |
|---|
T extends string |
Parameters
| Parameter | Type |
|---|---|
values | T[] |
Returns
this
version()
version(): thisMark this field as a version field for optimistic locking.
Returns
this
