core: Fields

Part of core, PocketBase's Go package core as JavaScript sees it. The same types in Go: core: Fields.

core.FieldFactoryFunc

FieldFactoryFunc defines a simple function to construct a specific Field instance.

core.Field

Field defines a common interface that all Collection fields should implement.

Member Type
getId() (): string GetId returns the field id.
setId() (id: string): void SetId changes the field id.
getName() (): string GetName returns the field name.
setName() (name: string): void SetName changes the field name.
getSystem() (): boolean GetSystem returns the field system flag state.
setSystem() (system: boolean): void SetSystem changes the field system flag state.
getHidden() (): boolean GetHidden returns the field hidden flag state.
setHidden() (hidden: boolean): void SetHidden changes the field hidden flag state.
type() (): string Type returns the unique type of the field.
columnType() (app: App): string ColumnType returns the DB column definition of the field.
prepareValue() (record: Record, raw: any): any PrepareValue returns a properly formatted field value based on the provided raw one.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateSettings validates the current field value associated with the provided record.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings validates the current field settings.

core.AutodateField

AutodateField defines an "autodate" type field, aka. field which datetime value could be auto set on record create/update.

This field is usually used for defining timestamp fields like "created" and "updated".

Requires either both or at least one of the OnCreate or OnUpdate options to be set.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
onCreate boolean OnCreate auto sets the current datetime as field value on record create.
onUpdate boolean OnUpdate auto sets the current datetime as field value on record update.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.
intercept() (ctx: context.Context, app: App, record: Record, actionName: string, actionFunc: () => void): void Intercept implements the RecordInterceptor interface.

core.BoolField

BoolField defines "bool" type field to store a single true/false value.

The respective zero record field value is false.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
required boolean Required will require the field value to be always "true".
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.

core.DateField

DateField defines "date" type field to store a single types.dateTime value.

The respective zero record field value is the zero types.dateTime.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
min types.DateTime Min specifies the min allowed field value.
max types.DateTime Max specifies the max allowed field value.
required boolean Required will require the field value to be non-zero types.dateTime.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.

core.EditorField

EditorField defines "editor" type field to store HTML formatted text.

The respective zero record field value is empty string.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
maxSize number MaxSize specifies the maximum size of the allowed field value (in bytes and up to 2^53-1).
convertURLs boolean ConvertURLs is usually used to instruct the editor whether to apply url conversion (eg. stripping the domain name in case the urls are using the same domain as the one where the editor is loaded).
required boolean Required will require the field value to be non-empty string.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
calculateMaxBodySize() (): number CalculateMaxBodySize implements the MaxBodySizeCalculator interface.

core.EmailField

EmailField defines "email" type field for storing a single email string address.

The respective zero record field value is empty string.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
exceptDomains Array<string> ExceptDomains will require the email domain to NOT be included in the listed ones.
onlyDomains Array<string> OnlyDomains will require the email domain to be included in the listed ones.
required boolean Required will require the field value to be non-empty email string.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.

core.FileField

FileField defines "file" type field for managing record file(s).

Only the file name is stored as part of the record value. New files (aka. files to upload) are expected to be of *filesystem.File.

If MaxSelect is not set or <= 1, then the field value is expected to be a single record id.

If MaxSelect is > 1, then the field value is expected to be a slice of record ids.

The respective zero record field value is either empty string (single) or empty string slice (multiple).


The following additional setter keys are available:

  - "fieldName+" - append one or more files to the existing record one. For example:

    // []string{"old1.txt", "old2.txt", "new1_ajkvass.txt", "new2_klhfnwd.txt"}
    record.Set("documents+", []*filesystem.File{new1, new2})

  - "+fieldName" - prepend one or more files to the existing record one. For example:

    // []string{"new1_ajkvass.txt", "new2_klhfnwd.txt", "old1.txt", "old2.txt",}
    record.Set("+documents", []*filesystem.File{new1, new2})

  - "fieldName-" - subtract/delete one or more files from the existing record one. For example:

    // []string{"old2.txt",}
    record.Set("documents-", "old1.txt")
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
maxSize number MaxSize specifies the maximum size of a single uploaded file (in bytes and up to 2^53-1).
maxSelect number MaxSelect specifies the max allowed files.
mimeTypes Array<string> MimeTypes specifies an optional list of the allowed file mime types.
thumbs Array<string> Thumbs specifies an optional list of the supported thumbs for image based files.
protected boolean Protected will require the users to provide a special file token to access the file.
required boolean Required will require the field value to have at least one file.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
isMultiple() (): boolean IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
driverValue() (record: Record): any DriverValue implements the DriverValuer interface.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
calculateMaxBodySize() (): number CalculateMaxBodySize implements the MaxBodySizeCalculator interface.
intercept() (ctx: context.Context, app: App, record: Record, actionName: string, actionFunc: () => void): void Intercept implements the RecordInterceptor interface.
findGetter() (key: string): GetterFunc FindGetter implements the GetterFinder interface.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.

core.GeoPointField

GeoPointField defines "geoPoint" type field for storing latitude and longitude GPS coordinates.

You can set the record field value as types.geoPoint, map or serialized json object with lat-lon props. The stored value is always converted to types.geoPoint. Nil, empty map, empty bytes slice, etc. results in zero types.geoPoint.

Examples of updating a record's GeoPointField value programmatically:

	record.Set("location", types.GeoPoint{Lat: 123, Lon: 456})
	record.Set("location", map[string]any{"lat":123, "lon":456})
	record.Set("location", []byte(`{"lat":123, "lon":456}`)
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
required boolean Required will require the field coordinates to be non-zero (aka. not "Null Island").
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.

core.JSONField

JSONField defines "json" type field for storing any serialized JSON value.

The respective zero record field value is the zero types.jSONRaw.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
maxSize number MaxSize specifies the maximum size of the allowed field value (in bytes and up to 2^53-1).
required boolean Required will require the field value to be non-empty JSON value (aka. not "null", "", "[]", "{}").
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
calculateMaxBodySize() (): number CalculateMaxBodySize implements the MaxBodySizeCalculator interface.

core.NumberField

NumberField defines "number" type field for storing numeric (float64) value.

The respective zero record field value is 0.

The following additional setter keys are available:

  - "fieldName+" - appends to the existing record value. For example:
    record.Set("total+", 5)
  - "fieldName-" - subtracts from the existing record value. For example:
    record.Set("total-", 5)
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
min? number Min specifies the min allowed field value.
max? number Max specifies the max allowed field value.
onlyInt boolean OnlyInt will require the field value to be integer.
required boolean Required will require the field value to be non-zero.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.

core.PasswordField

PasswordField defines "password" type field for storing bcrypt hashed strings (usually used only internally for the "password" auth collection system field).

If you want to set a direct bcrypt hash as record field value you can use the SetRaw method, for example:

	// generates a bcrypt hash of "123456" and set it as field value
	// (record.GetString("password") returns the plain password until persisted, otherwise empty string)
	record.Set("password", "123456")

	// set directly a bcrypt hash of "123456" as field value
	// (record.GetString("password") returns empty string)
	record.SetRaw("password", "$2a$10$.5Elh8fgxypNUWhpUUr/xOa2sZm0VIaE0qWuGGl9otUfobb46T1Pq")

The following additional getter keys are available:

  - "fieldName:hash" - returns the bcrypt hash string of the record field value (if any). For example:
    record.GetString("password:hash")
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
pattern string Pattern specifies an optional regex pattern to match against the field value.
min number Min specifies an optional required field string length.
max number Max specifies an optional required field string length.
cost number Cost specifies the cost/weight/iteration/etc. bcrypt factor.
required boolean Required will require the field value to be non-empty string.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
driverValue() (record: Record): any DriverValue implements the DriverValuer interface.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
intercept() (ctx: context.Context, app: App, record: Record, actionName: string, actionFunc: () => void): void Intercept implements the RecordInterceptor interface.
findGetter() (key: string): GetterFunc FindGetter implements the GetterFinder interface.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.

core.RelationField

RelationField defines "relation" type field for storing single or multiple collection record references.

Requires the CollectionId option to be set.

If MaxSelect is not set or <= 1, then the field value is expected to be a single record id.

If MaxSelect is > 1, then the field value is expected to be a slice of record ids.

The respective zero record field value is either empty string (single) or empty string slice (multiple).


The following additional setter keys are available:

  - "fieldName+" - append one or more values to the existing record one. For example:

    record.Set("categories+", []string{"new1", "new2"}) // []string{"old1", "old2", "new1", "new2"}

  - "+fieldName" - prepend one or more values to the existing record one. For example:

    record.Set("+categories", []string{"new1", "new2"}) // []string{"new1", "new2", "old1", "old2"}

  - "fieldName-" - subtract one or more values from the existing record one. For example:

    record.Set("categories-", "old1") // []string{"old2"}
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
collectionId string CollectionId is the id of the related collection.
cascadeDelete boolean CascadeDelete indicates whether the root model should be deleted in case of delete of all linked relations.
minSelect number MinSelect indicates the min number of allowed relation records that could be linked to the main model.
maxSelect number MaxSelect indicates the max number of allowed relation records that could be linked to the main model.
required boolean Required will require the field value to be non-empty.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
isMultiple() (): boolean IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
driverValue() (record: Record): any DriverValue implements the DriverValuer interface.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
findSetter() (key: string): SetterFunc FindSetter implements SetterFinder interface method.

core.SelectField

SelectField defines "select" type field for storing single or multiple string values from a predefined list.

Requires the Values option to be set.

If MaxSelect is not set or <= 1, then the field value is expected to be a single Values element.

If MaxSelect is > 1, then the field value is expected to be a subset of Values slice.

The respective zero record field value is either empty string (single) or empty string slice (multiple).


The following additional setter keys are available:

  - "fieldName+" - append one or more values to the existing record one. For example:

    record.Set("roles+", []string{"new1", "new2"}) // []string{"old1", "old2", "new1", "new2"}

  - "+fieldName" - prepend one or more values to the existing record one. For example:

    record.Set("+roles", []string{"new1", "new2"}) // []string{"new1", "new2", "old1", "old2"}

  - "fieldName-" - subtract one or more values from the existing record one. For example:

    record.Set("roles-", "old1") // []string{"old2"}
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
values Array<string> Values specifies the list of accepted values.
maxSelect number MaxSelect specifies the max allowed selected values.
required boolean Required will require the field value to be non-empty.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
isMultiple() (): boolean IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
driverValue() (record: Record): any DriverValue implements the DriverValuer interface.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.

core.TextField

TextField defines "text" type field for storing any string value.

The respective zero record field value is empty string.

The following additional setter keys are available:

  • "fieldName:autogenerate" - autogenerate field value if AutogeneratePattern is set. For example:
	record.Set("slug:autogenerate", "") // [random value]
	record.Set("slug:autogenerate", "abc-") // abc-[random value]
Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
min number Min specifies the minimum required string characters.
max number Max specifies the maximum allowed string characters.
pattern string Pattern specifies an optional regex pattern to match against the field value.
autogeneratePattern string AutogeneratePattern specifies an optional regex pattern that could be used to generate random string from it and set it automatically on record create if no explicit value is set or when the :autogenerate modifier is used.
required boolean Required will require the field value to be non-empty string.
primaryKey boolean PrimaryKey will mark the field as primary key.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validatePlainValue() (value: string): void ValidatePlainValue validates the provided string against the field options.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.
intercept() (ctx: context.Context, app: App, record: Record, actionName: string, actionFunc: () => void): void Intercept implements the RecordInterceptor interface.
findSetter() (key: string): SetterFunc FindSetter implements the SetterFinder interface.

core.URLField

URLField defines "url" type field for storing a single URL string value.

The respective zero record field value is empty string.

Member Type
name string Name (required) is the unique name of the field.
id string Id is the unique stable field identifier.
system boolean System prevents the renaming and removal of the field.
hidden boolean Hidden hides the field from the API response.
presentable boolean Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.
help string Help is an extra text explaining what the field is about. It is usually shown in Dashboard UI under the field input.
exceptDomains Array<string> ExceptDomains will require the URL domain to NOT be included in the listed ones.
onlyDomains Array<string> OnlyDomains will require the URL domain to be included in the listed ones.
required boolean Required will require the field value to be non-empty URL string.
type() (): string Type implements Field.type interface method.
getId() (): string GetId implements Field.getId interface method.
setId() (id: string): void SetId implements Field.setId interface method.
getName() (): string GetName implements Field.getName interface method.
setName() (name: string): void SetName implements Field.setName interface method.
getSystem() (): boolean GetSystem implements Field.getSystem interface method.
setSystem() (system: boolean): void SetSystem implements Field.setSystem interface method.
getHidden() (): boolean GetHidden implements Field.getHidden interface method.
setHidden() (hidden: boolean): void SetHidden implements Field.setHidden interface method.
columnType() (app: App): string ColumnType implements Field.columnType interface method.
prepareValue() (record: Record, raw: any): any PrepareValue implements Field.prepareValue interface method.
validateValue() (ctx: context.Context, app: App, record: Record): void ValidateValue implements Field.validateValue interface method.
validateSettings() (ctx: context.Context, app: App, collection: Collection): void ValidateSettings implements Field.validateSettings interface method.

core.FieldsList

FieldsList defines a Collection slice of fields.

Has everything Array<Field> has.

Member Type
clone() (): FieldsList Clone creates a deep clone of the current list.
fieldNames() (): Array<string> FieldNames returns a slice with the name of all list fields.
asMap() (): { [key: string]: any } AsMap returns a map with all registered list field. The returned map is indexed with each field name.
getById() (fieldId: string): Field GetById returns a single field by its id.
getByName() (fieldName: string): Field GetByName returns a single field by its name.
removeById() (fieldId: string): void RemoveById removes a single field by its id.
removeByName() (fieldName: string): void RemoveByName removes a single field by its name.
add() (...fields: Field[]): void Add adds one or more fields to the current list.
addAt() (pos: number, ...fields: Field[]): void AddAt is the same as Add but insert/move the fields at the specific position.
addMarshaledJSON() (rawJSON: string|Array<number>): void AddMarshaledJSON parses the provided raw json data and adds the found fields into the current list (following the same rule as the Add method).
addMarshaledJSONAt() (pos: number, rawJSON: string|Array<number>): void AddMarshaledJSONAt is the same as AddMarshaledJSON but insert/move the fields at the specific position.
string() (): string String returns the string representation of the current list.
unmarshalJSON() (data: string|Array<number>): void UnmarshalJSON implements json.unmarshaler and loads the provided json data into the current FieldsList.
marshalJSON() (): string|Array<number> MarshalJSON implements the json.marshaler interface.
value() (): any Value implements the driver.valuer interface.
scan() (value: any): void Scan implements sql.scanner interface to scan the provided value into the current FieldsList instance.

core.queryField