Back to Pocketbase

Interface RelationField

static/jsvm/interfaces/core.RelationField.html

latest7.5 KB
Original Source

Interface 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"}Copy

Hierarchy

Implemented by

Index

Methods

columnTypedriverValuefindSettergetHiddengetIdgetNamegetSystemisMultipleprepareValuesetHiddensetIdsetNamesetSystemtypevalidateSettingsvalidateValue

Properties

cascadeDeletecollectionIdhiddenidmaxSelectminSelectnamepresentablerequiredsystem

Methods

columnType

  • columnType(app): string

ColumnType implements [Field.ColumnType] interface method.

Parameters

app: App

Returns string

driverValue

  • driverValue(record): any

DriverValue implements the [DriverValuer] interface.

Parameters

record: core.Record

Returns any

findSetter

FindSetter implements [SetterFinder] interface method.

Parameters

key: string

Returns SetterFunc

getHidden

  • getHidden(): boolean

GetHidden implements [Field.GetHidden] interface method.

Returns boolean

getId

  • getId(): string

GetId implements [Field.GetId] interface method.

Returns string

getName

  • getName(): string

GetName implements [Field.GetName] interface method.

Returns string

getSystem

  • getSystem(): boolean

GetSystem implements [Field.GetSystem] interface method.

Returns boolean

isMultiple

  • isMultiple(): boolean

IsMultiple implements [MultiValuer] interface and checks whether the current field options support multiple values.

Returns boolean

prepareValue

  • prepareValue(record, raw): any

PrepareValue implements [Field.PrepareValue] interface method.

Parameters

record: core.Record
raw: any

Returns any

setHidden

  • setHidden(hidden): void

SetHidden implements [Field.SetHidden] interface method.

Parameters

hidden: boolean

Returns void

setId

  • setId(id): void

SetId implements [Field.SetId] interface method.

Parameters

id: string

Returns void

setName

  • setName(name): void

SetName implements [Field.SetName] interface method.

Parameters

name: string

Returns void

setSystem

  • setSystem(system): void

SetSystem implements [Field.SetSystem] interface method.

Parameters

system: boolean

Returns void

type

  • type(): string

Type implements [Field.Type] interface method.

Returns string

validateSettings

  • validateSettings(ctx, app, collection): void

ValidateSettings implements [Field.ValidateSettings] interface method.

Parameters

ctx: context.Context
app: App
collection: core.Collection

Returns void

validateValue

  • validateValue(ctx, app, record): void

ValidateValue implements [Field.ValidateValue] interface method.

Parameters

ctx: context.Context
app: App
record: core.Record

Returns void

Properties

cascadeDelete

cascadeDelete: boolean

CascadeDelete indicates whether the root model should be deleted in case of delete of all linked relations.

collectionId

collectionId: string

CollectionId is the id of the related collection.

hidden

hidden: boolean

Hidden hides the field from the API response.

id

id: string

Id is the unique stable field identifier.

It is automatically generated from the name when adding to a collection FieldsList.

maxSelect

maxSelect: number

MaxSelect indicates the max number of allowed relation records that could be linked to the main model.

For multiple select the value must be > 1, otherwise fallbacks to single (default).

If MinSelect is set, MaxSelect must be at least >= MinSelect.

minSelect

minSelect: number

MinSelect indicates the min number of allowed relation records that could be linked to the main model.

No min limit is applied if it is zero or negative value.

name

name: string

Name (required) is the unique name of the field.

presentable

presentable: boolean

Presentable hints the Dashboard UI to use the underlying field record value in the relation preview label.

required

required: boolean

Required will require the field value to be non-empty.

system

system: boolean

System prevents the renaming and removal of the field.

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

On This Page

Generated using TypeDoc