LogoRobo.js
Framework

Field<Type, Optional, Custom>

Class: Field<Type, Optional, Custom>

Field builder class with fluent modifiers.

Type Parameters

Type ParameterDefault type
Type extends FieldTypeFieldType
Optional extends booleanfalse
Customunknown

Constructors

new Field()

new Field<Type, Optional, Custom>(type): Field<Type, Optional, Custom>

Parameters

ParameterType
typeType

Returns

Field<Type, Optional, Custom>

Properties

PropertyModifierType
_defreadonlyFieldDef
_isRelationreadonlyfalse

Methods

default()

default(value): this

Set a default value for this field. Can be a static value or a factory function.

Parameters

ParameterType
valueInferType<Type, Custom> | () => InferType<Type, Custom>

Returns

this


indexed()

indexed(): this

Mark this field as indexed (creates sorted index).

Returns

this


indexedWith()

indexedWith(type): this

Mark this field with custom index type(s).

Parameters

ParameterType
typestring | string[]

Returns

this


optional()

optional(): Field<Type, true, Custom>

Mark this field as optional.

Returns

Field<Type, true, Custom>


primaryKey()

primaryKey(): this

Mark this field as the primary key.

Returns

this


unique()

unique(): this

Mark this field as unique (creates unique constraint).

Returns

this


values()

values<T>(values): this

Set allowed enum values (for enum type).

Type Parameters

Type Parameter
T extends string

Parameters

ParameterType
valuesT[]

Returns

this


version()

version(): this

Mark this field as a version field for optimistic locking.

Returns

this

On this page