Back to Pocketbase

Interface Collection

static/jsvm/interfaces/core.Collection.html

latest11.0 KB
Original Source

Interface Collection

Collection defines the table, fields and various options related to a set of records.

Hierarchy

Implemented by

Index

Methods

addIndexbaseFilesPathdbExportgetIndexintegrityChecksisAuthisBaseisNewisViewlastSavedPKmarkAsNewmarkAsNotNewmarshalJSONpkpostScanremoveIndexstringtableNameunmarshalJSON

Properties

authAlertauthRule?authTokenconfirmEmailChangeTemplatecreateRule?createddeleteRule?emailChangeTokenfieldsfileTokenidindexeslistRule?manageRule?mfanameoauth2otppasswordAuthpasswordResetTokenrawOptionsresetPasswordTemplatesystemtypeupdateRule?updatedverificationTemplateverificationTokenviewQueryviewRule?

Methods

addIndex

  • addIndex(name, unique, columnsExpr, optWhereExpr): void

AddIndex adds a new index into the current collection.

If the collection has an existing index matching the new name it will be replaced with the new one.

Parameters

name: string
unique: boolean
columnsExpr: string
optWhereExpr: string

Returns void

baseFilesPath

  • baseFilesPath(): string

BaseFilesPath returns the storage dir path used by the collection.

Returns string

dbExport

DBExport prepares and exports the current collection data for db persistence.

Parameters

app: App

Returns _TygojaDict

getIndex

  • getIndex(name): string

GetIndex returns s single Collection index expression by its name.

Parameters

name: string

Returns string

integrityChecks

  • integrityChecks(enable): void

IntegrityChecks toggles the current collection integrity checks (ex. checking references on delete).

Parameters

enable: boolean

Returns void

isAuth

  • isAuth(): boolean

IsAuth checks if the current collection has "auth" type.

Returns boolean

isBase

  • isBase(): boolean

IsBase checks if the current collection has "base" type.

Returns boolean

isNew

  • isNew(): boolean

IsNew indicates what type of db query (insert or update) should be used with the model instance.

Returns boolean

isView

  • isView(): boolean

IsView checks if the current collection has "view" type.

Returns boolean

lastSavedPK

  • lastSavedPK(): any

LastSavedPK returns the last saved primary key of the model.

Its value is updated to the latest PK value after MarkAsNotNew() or PostScan() calls.

Returns any

markAsNew

  • markAsNew(): void

MarkAsNew clears the pk field and marks the current model as "new" (aka. forces m.IsNew() to be true).

Returns void

markAsNotNew

  • markAsNotNew(): void

MarkAsNew set the pk field to the Id value and marks the current model as NOT "new" (aka. forces m.IsNew() to be false).

Returns void

marshalJSON

  • marshalJSON(): string | number[]

MarshalJSON implements the [json.Marshaler] interface.

Note that non-type related fields are ignored from the serialization (ex. for "view" collections the "auth" fields are skipped).

Returns string | number[]

pk

  • pk(): any

Returns any

postScan

  • postScan(): void

PostScan implements the [dbx.PostScanner] interface to auto unmarshal the raw serialized options into the concrete type specific fields.

Returns void

removeIndex

  • removeIndex(name): void

RemoveIndex removes a single index with the specified name from the current collection.

Parameters

name: string

Returns void

string

  • string(): string

String returns a string representation of the current collection.

Returns string

tableName

  • tableName(): string

TableName returns the Collection model SQL table name.

Returns string

unmarshalJSON

  • unmarshalJSON(b): void

UnmarshalJSON implements the [json.Unmarshaler] interface.

For new/"blank" Collection models it replaces the model with a factory instance and then unmarshal the provided data one on top of it.

Parameters

b: string | number[]

Returns void

Properties

authAlert

authAlert: AuthAlertConfig

AuthAlert defines options related to the auth alerts on new device login.

Optional authRule

authRule?: string

AuthRule could be used to specify additional record constraints applied after record authentication and right before returning the auth token response to the client.

For example, to allow only verified users you could set it to "verified = true".

Set it to empty string to allow any Auth collection record to authenticate.

Set it to nil to disallow authentication altogether for the collection (that includes password, OAuth2, etc.).

authToken

authToken: TokenConfig

Various token configurations

confirmEmailChangeTemplate

confirmEmailChangeTemplate: EmailTemplate

Optional createRule

createRule?: string

created

created: types.DateTime

Optional deleteRule

deleteRule?: string

emailChangeToken

emailChangeToken: TokenConfig

fields

fields: core.FieldsList

fileToken

fileToken: TokenConfig

id

id: string

Id is the primary key of the model. It is usually autogenerated by the parent model implementation.

indexes

indexes: JSONArray<string>

Optional listRule

listRule?: string

Optional manageRule

manageRule?: string

ManageRule gives admin-like permissions to allow fully managing the auth record(s), eg. changing the password without requiring to enter the old one, directly updating the verified state and email, etc.

This rule is executed in addition to the Create and Update API rules.

mfa

mfa: MFAConfig

MFA defines options related to the Multi-factor authentication (MFA).

name

name: string

oauth2

oauth2: OAuth2Config

OAuth2 specifies whether OAuth2 auth is enabled for the collection and which OAuth2 providers are allowed.

otp

otp: OTPConfig

OTP defines options related to the One-time password authentication (OTP).

passwordAuth

passwordAuth: PasswordAuthConfig

PasswordAuth defines options related to the collection password authentication.

passwordResetToken

passwordResetToken: TokenConfig

rawOptions

rawOptions: JSONRaw

RawOptions represents the raw serialized collection option loaded from the DB. NB! This field shouldn't be modified manually. It is automatically updated with the collection type specific option before save.

resetPasswordTemplate

resetPasswordTemplate: EmailTemplate

system

system: boolean

System prevents the collection rename, deletion and rules change. It is used primarily for internal purposes for collections like "_superusers", "_externalAuths", etc.

type

type: string

Optional updateRule

updateRule?: string

updated

updated: types.DateTime

verificationTemplate

verificationTemplate: EmailTemplate

Default email templates

verificationToken

verificationToken: TokenConfig

viewQuery

viewQuery: string

Optional viewRule

viewRule?: string

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

On This Page

Generated using TypeDoc