core

Types from PocketBase's Go package core, as JavaScript sees them: you get these objects from $app and the other globals and from hook events, and call their methods by their JS names (Go's FindRecordById is findRecordById). The same package in Go: core.

Its types are on five pages: this one (the app, core.App, and what doesn't fit elsewhere), Records and collections, Fields, Events, Settings.

core.App

App defines the main PocketBase app interface.

Note that the interface is not intended to be implemented manually by users and instead they should use core.BaseApp (either directly or as embedded field in a custom struct).

This interface exists to make testing easier and to allow users to create common and pluggable helpers and methods that doesn't rely on a specific wrapped app struct (hence the large interface size).

Member Type
unsafeWithoutHooks() (): App UnsafeWithoutHooks returns a shallow copy of the current app WITHOUT any registered hooks.
logger() (): (slog.Logger) Logger returns the default app logger.
isBootstrapped() (): boolean IsBootstrapped checks if the application was initialized (aka. whether Bootstrap() was called).
isTransactional() (): boolean IsTransactional checks if the current app instance is part of a transaction.
txInfo() (): (TxAppInfo) TxInfo returns the transaction associated with the current app instance (if any).
bootstrap() (): void Bootstrap initializes the application (aka. create data dir, open db connections, load settings, etc.).
clearBootstrap() (): void ClearBootstrap releases the initialized core app resources (closing db connections, stopping cron ticker, etc.).
resetBootstrapState() (): void Deprecated: use ClearBootstrap().
dataDir() (): string DataDir returns the app data directory path.
encryptionEnv() (): string EncryptionEnv returns the name of the app secret env key (currently used primarily for optional settings encryption but this may change in the future).
isDev() (): boolean IsDev returns whether the app is in dev mode.
settings() (): (Settings) Settings returns the loaded app settings.
store() (): (store.Store<string, any>) Store returns the app runtime store.
cron() (): (cron.Cron) Cron returns the app cron instance.
subscriptionsBroker() (): (subscriptions.Broker) SubscriptionsBroker returns the app realtime subscriptions broker instance.
newMailClient() (): mailer.Mailer NewMailClient creates and returns a new SMTP or Sendmail client based on the current app settings.
newFilesystem() (): (filesystem.System) NewFilesystem creates a new local or S3 filesystem instance for managing regular app files (ex. record uploads) based on the current app settings.
newBackupsFilesystem() (): (filesystem.System) NewBackupsFilesystem creates a new local or S3 filesystem instance for managing app backups based on the current app settings.
reloadSettings() (): void ReloadSettings reinitializes and reloads the stored application settings.
createBackup() (ctx: context.Context, name: string): void CreateBackup creates a new backup of the current app pb_data directory.
restoreBackup() (ctx: context.Context, name: string): void RestoreBackup restores the backup with the specified name and restarts the current running application process.
restart() (): void Restart restarts (aka. replaces) the current running application process.
runSystemMigrations() (): void RunSystemMigrations applies all new migrations registered in the core.systemMigrations list.
runAppMigrations() (): void RunAppMigrations applies all new migrations registered in the CoreAppMigrations list.
runAllMigrations() (): void RunAllMigrations applies all system and app migrations (aka. from both core.systemMigrations and CoreAppMigrations).
db() (): dbx.Builder DB returns the default app data.db builder instance.
concurrentDB() (): dbx.Builder ConcurrentDB returns the concurrent app data.db builder instance.
nonconcurrentDB() (): dbx.Builder NonconcurrentDB returns the nonconcurrent app data.db builder instance.
auxDB() (): dbx.Builder AuxDB returns the app auxiliary.db builder instance.
auxConcurrentDB() (): dbx.Builder AuxConcurrentDB returns the concurrent app auxiliary.db builder instance.
auxNonconcurrentDB() (): dbx.Builder AuxNonconcurrentDB returns the nonconcurrent app auxiliary.db builder instance.
hasTable() (tableName: string): boolean HasTable checks if a table (or view) with the provided name exists (case insensitive). in the data.db.
auxHasTable() (tableName: string): boolean AuxHasTable checks if a table (or view) with the provided name exists (case insensitive) in the auxiliary.db.
tableColumns() (tableName: string): Array<string> TableColumns returns all column names of a single table by its name.
tableInfo() (tableName: string): Array<(TableInfoRow | undefined)> TableInfo returns the "table_info" pragma result for the specified table.
tableIndexes() (tableName: string): { [key: string]: any } TableIndexes returns a name grouped map with all non empty index of the specified table.
deleteTable() (dangerousTableName: string): void DeleteTable drops the specified table.
deleteView() (dangerousViewName: string): void DeleteView drops the specified view name.
saveView() (dangerousViewName: string, dangerousSelectQuery: string): void SaveView creates (or updates already existing) persistent SQL view.
createViewFields() (dangerousSelectQuery: string): FieldsList CreateViewFields creates a new FieldsList from the provided select query.
dryRunView() (dangerousSelectQuery: string, sampleSize: number): (DryRunViewResult) DryRunView executes the provided query by creating a temporary view collection and returning a sample of the resulting query records (if valid).
findRecordByViewFile() (viewCollectionModelOrIdentifier: any, fileFieldName: string, filename: string): (Record) FindRecordByViewFile returns the original Record of the provided view collection file.
vacuum() (): void Vacuum executes VACUUM on the data.db in order to reclaim unused data db disk space.
auxVacuum() (): void AuxVacuum executes VACUUM on the auxiliary.db in order to reclaim unused auxiliary db disk space.
modelQuery() (model: Model): (dbx.SelectQuery) ModelQuery creates a new preconfigured select data.db query with preset SELECT, FROM and other common fields based on the provided model.
auxModelQuery() (model: Model): (dbx.SelectQuery) AuxModelQuery creates a new preconfigured select auxiliary.db query with preset SELECT, FROM and other common fields based on the provided model.
delete() (model: Model): void Delete deletes the specified model from the regular app database.
deleteWithContext() (ctx: context.Context, model: Model): void Delete deletes the specified model from the regular app database (the context could be used to limit the query execution).
auxDelete() (model: Model): void AuxDelete deletes the specified model from the auxiliary database.
auxDeleteWithContext() (ctx: context.Context, model: Model): void AuxDeleteWithContext deletes the specified model from the auxiliary database (the context could be used to limit the query execution).
save() (model: Model): void Save validates and saves the specified model into the regular app database.
saveWithContext() (ctx: context.Context, model: Model): void SaveWithContext is the same as [App.Save()] but allows specifying a context to limit the db execution.
saveNoValidate() (model: Model): void SaveNoValidate saves the specified model into the regular app database without performing validations.
saveNoValidateWithContext() (ctx: context.Context, model: Model): void SaveNoValidateWithContext is the same as [App.SaveNoValidate()] but allows specifying a context to limit the db execution.
auxSave() (model: Model): void AuxSave validates and saves the specified model into the auxiliary app database.
auxSaveWithContext() (ctx: context.Context, model: Model): void AuxSaveWithContext is the same as [App.AuxSave()] but allows specifying a context to limit the db execution.
auxSaveNoValidate() (model: Model): void AuxSaveNoValidate saves the specified model into the auxiliary app database without performing validations.
auxSaveNoValidateWithContext() (ctx: context.Context, model: Model): void AuxSaveNoValidateWithContext is the same as [App.AuxSaveNoValidate()] but allows specifying a context to limit the db execution.
validate() (model: Model): void Validate triggers the OnModelValidate hook for the specified model.
validateWithContext() (ctx: context.Context, model: Model): void ValidateWithContext is the same as Validate but allows specifying the ModelEvent context.
runInTransaction() (fn: (txApp: App) => void): void RunInTransaction wraps fn into a transaction for the regular app database.
auxRunInTransaction() (fn: (txApp: App) => void): void AuxRunInTransaction wraps fn into a transaction for the auxiliary app database.
logQuery() (): (dbx.SelectQuery) LogQuery returns a new Log select query.
findLogById() (id: string): (Log) FindLogById finds a single Log entry by its id.
logsStats() (expr: dbx.Expression): Array<(LogsStatsItem | undefined)> LogsStatsItem returns hourly grouped logs statistics.
countLogs() (...exprs: dbx.Expression[]): number CountLogs returns the total number of log entries.
deleteOldLogs() (createdBefore: time.Time): void DeleteOldLogs delete all logs that are created before createdBefore.
collectionQuery() (): (dbx.SelectQuery) CollectionQuery returns a new Collection select query.
findAllCollections() (...collectionTypes: string[]): Array<(Collection | undefined)> FindCollections finds all collections by the given type(s).
reloadCachedCollections() (): void ReloadCachedCollections fetches all collections and caches them into the app store.
findCollectionByNameOrId() (nameOrId: string): (Collection) FindCollectionByNameOrId finds a single collection by its name (case insensitive) or id.s
findCachedCollectionByNameOrId() (nameOrId: string): (Collection) FindCachedCollectionByNameOrId is similar to App.findCollectionByNameOrId but retrieves the Collection from the app cache instead of making a db call.
findCollectionReferences() (collection: Collection, ...excludeIds: string[]): { [key: string]: any } FindCollectionReferences returns information for all relation fields referencing the provided collection.
findCachedCollectionReferences() (collection: Collection, ...excludeIds: string[]): { [key: string]: any } FindCachedCollectionReferences is similar to App.findCollectionReferences but retrieves the Collection from the app cache instead of making a db call.
isCollectionNameUnique() (name: string, ...excludeIds: string[]): boolean IsCollectionNameUnique checks that there is no existing collection with the provided name (case insensitive!).
truncateCollection() (collection: Collection): void TruncateCollection deletes all records associated with the provided collection.
importCollections() (toImport: Array<{ [key: string]: any }>, deleteMissing: boolean): void ImportCollections imports the provided collections data in a single transaction.
importCollectionsByMarshaledJSON() (rawSliceOfMaps: string|Array<number>, deleteMissing: boolean): void ImportCollectionsByMarshaledJSON is the same as ImportCollections but accept marshaled json array as import data (usually used for the autogenerated snapshots).
syncRecordTableSchema() (newCollection: Collection, oldCollection: Collection): void SyncRecordTableSchema compares the two provided collections and applies the necessary related record table changes.
findAllExternalAuthsByRecord() (authRecord: Record): Array<(ExternalAuth | undefined)> FindAllExternalAuthsByRecord returns all ExternalAuth models linked to the provided auth record.
findAllExternalAuthsByCollection() (collection: Collection): Array<(ExternalAuth | undefined)> FindAllExternalAuthsByCollection returns all ExternalAuth models linked to the provided auth collection.
findFirstExternalAuthByExpr() (expr: dbx.Expression): (ExternalAuth) FindFirstExternalAuthByExpr returns the first available (the most recent created) ExternalAuth model that satisfies the non-nil expression.
deleteAllExternalAuthsByRecord() (authRecord: Record): void DeleteAllExternalAuthsByRecord deletes all ExternalAuth models associated with the provided record.
findAllMFAsByRecord() (authRecord: Record): Array<(MFA | undefined)> FindAllMFAsByRecord returns all MFA models linked to the provided auth record.
findAllMFAsByCollection() (collection: Collection): Array<(MFA | undefined)> FindAllMFAsByCollection returns all MFA models linked to the provided collection.
findMFAById() (id: string): (MFA) FindMFAById returns a single MFA model by its id.
deleteAllMFAsByRecord() (authRecord: Record): void DeleteAllMFAsByRecord deletes all MFA models associated with the provided record.
deleteExpiredMFAs() (): void DeleteExpiredMFAs deletes the expired MFAs for all auth collections.
findAllOTPsByRecord() (authRecord: Record): Array<(OTP | undefined)> FindAllOTPsByRecord returns all OTP models linked to the provided auth record.
findAllOTPsByCollection() (collection: Collection): Array<(OTP | undefined)> FindAllOTPsByCollection returns all OTP models linked to the provided collection.
findOTPById() (id: string): (OTP) FindOTPById returns a single OTP model by its id.
deleteAllOTPsByRecord() (authRecord: Record): void DeleteAllOTPsByRecord deletes all OTP models associated with the provided record.
deleteExpiredOTPs() (): void DeleteExpiredOTPs deletes the expired OTPs for all auth collections.
findAllAuthOriginsByRecord() (authRecord: Record): Array<(AuthOrigin | undefined)> FindAllAuthOriginsByRecord returns all AuthOrigin models linked to the provided auth record (in DESC order).
findAllAuthOriginsByCollection() (collection: Collection): Array<(AuthOrigin | undefined)> FindAllAuthOriginsByCollection returns all AuthOrigin models linked to the provided collection (in DESC order).
findAuthOriginById() (id: string): (AuthOrigin) FindAuthOriginById returns a single AuthOrigin model by its id.
findAuthOriginByRecordAndFingerprint() (authRecord: Record, fingerprint: string): (AuthOrigin) FindAuthOriginByRecordAndFingerprint returns a single AuthOrigin model by its authRecord relation and fingerprint.
deleteAllAuthOriginsByRecord() (authRecord: Record): void DeleteAllAuthOriginsByRecord deletes all AuthOrigin models associated with the provided record.
recordQuery() (collectionModelOrIdentifier: any): (dbx.SelectQuery) RecordQuery returns a new Record select query from a collection model, id or name.
findRecordById() (collectionModelOrIdentifier: any, recordId: string, ...optFilters: ((q: dbx.SelectQuery) => void)[]): (Record) FindRecordById finds the Record model by its id.
findRecordsByIds() (collectionModelOrIdentifier: any, recordIds: Array<string>, ...optFilters: ((q: dbx.SelectQuery) => void)[]): Array<(Record | undefined)> FindRecordsByIds finds all records by the specified ids. If no records are found, returns an empty slice.
findAllRecords() (collectionModelOrIdentifier: any, ...exprs: dbx.Expression[]): Array<(Record | undefined)> FindAllRecords finds all records matching specified db expressions.
findFirstRecordByData() (collectionModelOrIdentifier: any, key: string, value: any): (Record) FindFirstRecordByData returns the first found record matching the provided key-value pair.
findRecordsByFilter() (collectionModelOrIdentifier: any, filter: string, sort: string, limit: number, offset: number, ...params: dbx.Params[]): Array<(Record | undefined)> FindRecordsByFilter returns limit number of records matching the provided string filter.
findFirstRecordByFilter() (collectionModelOrIdentifier: any, filter: string, ...params: dbx.Params[]): (Record) FindFirstRecordByFilter returns the first available record matching the provided filter (if any).
countRecords() (collectionModelOrIdentifier: any, ...exprs: dbx.Expression[]): number CountRecords returns the total number of records in a collection.
findAuthRecordByToken() (token: string, ...validTypes: string[]): (Record) FindAuthRecordByToken finds the auth record associated with the provided JWT (auth, file, verifyEmail, changeEmail, passwordReset types).
findAuthRecordByEmail() (collectionModelOrIdentifier: any, email: string): (Record) FindAuthRecordByEmail finds the auth record associated with the provided email.
canAccessRecord() (record: Record, requestInfo: RequestInfo, accessRule: string): boolean CanAccessRecord checks if a record is allowed to be accessed by the specified requestInfo and accessRule.
expandRecord() (record: Record, expands: Array<string>, optFetchFunc: ExpandFetchFunc): { [key: string]: any } ExpandRecord expands the relations of a single Record model.
expandRecords() (records: Array<(Record | undefined)>, expands: Array<string>, optFetchFunc: ExpandFetchFunc): { [key: string]: any } ExpandRecords expands the relations of the provided Record models list.
onBootstrap() (): (hook.Hook<BootstrapEvent | undefined>) OnBootstrap hook is triggered when initializing the main application resources (db, app settings, etc).
onBootstrapClear() (): (hook.Hook<BootstrapEvent | undefined>) OnBootstrapClear hook is triggered when clearing the main application resources (db connections, cron, logger, etc.)
onServe() (): (hook.Hook<ServeEvent | undefined>) OnServe hook is triggered when the app web server is started (after starting the TCP listener but before initializing the blocking serve task), allowing you to adjust its options and attach new routes or middlewares.
onTerminate() (): (hook.Hook<TerminateEvent | undefined>) OnTerminate hook is triggered when the app is in the process of being terminated (ex. on SIGTERM signal).
onBackupCreate() (): (hook.Hook<BackupEvent | undefined>) OnBackupCreate hook is triggered on each App.createBackup call.
onBackupRestore() (): (hook.Hook<BackupEvent | undefined>) OnBackupRestore hook is triggered before app backup restore (aka. App.restoreBackup call).
onModelValidate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelValidate is triggered every time when a model is being validated (e.g. triggered by App.Validate() or App.Save()).
onModelCreate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelCreate is triggered every time when a new model is being created (e.g. triggered by App.Save()).
onModelCreateExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelCreateExecute is triggered after successful Model validation and right before the model INSERT DB statement execution.
onModelAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelAfterCreateSuccess is triggered after each successful Model DB create persistence.
onModelAfterCreateError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>) OnModelAfterCreateError is triggered after each failed Model DB create persistence.
onModelUpdate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelUpdate is triggered every time when a new model is being updated (e.g. triggered by App.Save()).
onModelUpdateExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelUpdateExecute is triggered after successful Model validation and right before the model UPDATE DB statement execution.
onModelAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelAfterUpdateSuccess is triggered after each successful Model DB update persistence.
onModelAfterUpdateError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>) OnModelAfterUpdateError is triggered after each failed Model DB update persistence.
onModelDelete() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelDelete is triggered every time when a new model is being deleted (e.g. triggered by App.Delete()).
onModelDeleteExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelUpdateExecute is triggered right before the model DELETE DB statement execution.
onModelAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>) OnModelAfterDeleteSuccess is triggered after each successful Model DB delete persistence.
onModelAfterDeleteError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>) OnModelAfterDeleteError is triggered after each failed Model DB delete persistence.
onRecordEnrich() (...tags: string[]): (hook.TaggedHook<RecordEnrichEvent | undefined>) OnRecordEnrich is triggered every time when a record is enriched (as part of the builtin Record responses, during realtime message seriazation, or when apis.enrichRecord is invoked).
onRecordValidate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordValidate is a Record proxy model hook of OnModelValidate.
onRecordCreate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordCreate is a Record proxy model hook of OnModelCreate.
onRecordCreateExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordCreateExecute is a Record proxy model hook of OnModelCreateExecute.
onRecordAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordAfterCreateSuccess is a Record proxy model hook of OnModelAfterCreateSuccess.
onRecordAfterCreateError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>) OnRecordAfterCreateError is a Record proxy model hook of OnModelAfterCreateError.
onRecordUpdate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordUpdate is a Record proxy model hook of OnModelUpdate.
onRecordUpdateExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordUpdateExecute is a Record proxy model hook of OnModelUpdateExecute.
onRecordAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordAfterUpdateSuccess is a Record proxy model hook of OnModelAfterUpdateSuccess.
onRecordAfterUpdateError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>) OnRecordAfterUpdateError is a Record proxy model hook of OnModelAfterUpdateError.
onRecordDelete() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordDelete is a Record proxy model hook of OnModelDelete.
onRecordDeleteExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordDeleteExecute is a Record proxy model hook of OnModelDeleteExecute.
onRecordAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>) OnRecordAfterDeleteSuccess is a Record proxy model hook of OnModelAfterDeleteSuccess.
onRecordAfterDeleteError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>) OnRecordAfterDeleteError is a Record proxy model hook of OnModelAfterDeleteError.
onCollectionValidate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionValidate is a Collection proxy model hook of OnModelValidate.
onCollectionCreate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionCreate is a Collection proxy model hook of OnModelCreate.
onCollectionCreateExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionCreateExecute is a Collection proxy model hook of OnModelCreateExecute.
onCollectionAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionAfterCreateSuccess is a Collection proxy model hook of OnModelAfterCreateSuccess.
onCollectionAfterCreateError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>) OnCollectionAfterCreateError is a Collection proxy model hook of OnModelAfterCreateError.
onCollectionUpdate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionUpdate is a Collection proxy model hook of OnModelUpdate.
onCollectionUpdateExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionUpdateExecute is a Collection proxy model hook of OnModelUpdateExecute.
onCollectionAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionAfterUpdateSuccess is a Collection proxy model hook of OnModelAfterUpdateSuccess.
onCollectionAfterUpdateError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>) OnCollectionAfterUpdateError is a Collection proxy model hook of OnModelAfterUpdateError.
onCollectionDelete() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionDelete is a Collection proxy model hook of OnModelDelete.
onCollectionDeleteExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionDeleteExecute is a Collection proxy model hook of OnModelDeleteExecute.
onCollectionAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>) OnCollectionAfterDeleteSuccess is a Collection proxy model hook of OnModelAfterDeleteSuccess.
onCollectionAfterDeleteError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>) OnCollectionAfterDeleteError is a Collection proxy model hook of OnModelAfterDeleteError.
onMailerSend() (): (hook.Hook<MailerEvent | undefined>) OnMailerSend hook is triggered every time when a new email is being sent using the [App.NewMailClient()] instance.
onMailerRecordAuthAlertSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>) OnMailerRecordAuthAlertSend hook is triggered when sending a new device login auth alert email, allowing you to intercept and customize the email message that is being sent.
onMailerRecordPasswordResetSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>) OnMailerBeforeRecordResetPasswordSend hook is triggered when sending a password reset email to an auth record, allowing you to intercept and customize the email message that is being sent.
onMailerRecordVerificationSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>) OnMailerBeforeRecordVerificationSend hook is triggered when sending a verification email to an auth record, allowing you to intercept and customize the email message that is being sent.
onMailerRecordEmailChangeSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>) OnMailerRecordEmailChangeSend hook is triggered when sending a confirmation new address email to an auth record, allowing you to intercept and customize the email message that is being sent.
onMailerRecordOTPSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>) OnMailerRecordOTPSend hook is triggered when sending an OTP email to an auth record, allowing you to intercept and customize the email message that is being sent.
onFilesystemCreate() (): (hook.Hook<FilesystemCreateEvent | undefined>) PocketOne: OnFilesystemCreate hook is triggered every time app.NewFilesystem() or app.NewBackupsFilesystem() creates a filesystem, before the default one. A handler may supply its own (see FilesystemCreateEvent). Plugins may trigger it for their own kinds too.
onRealtimeConnectRequest() (): (hook.Hook<RealtimeConnectRequestEvent | undefined>) OnRealtimeConnectRequest hook is triggered when establishing the SSE client connection.
onRealtimeMessageSend() (): (hook.Hook<RealtimeMessageEvent | undefined>) OnRealtimeMessageSend hook is triggered when sending an SSE message to a client.
onRealtimeSubscribeRequest() (): (hook.Hook<RealtimeSubscribeRequestEvent | undefined>) OnRealtimeSubscribeRequest hook is triggered when updating the client subscriptions, allowing you to further validate and modify the submitted change.
onSettingsListRequest() (): (hook.Hook<SettingsListRequestEvent | undefined>) OnSettingsListRequest hook is triggered on each API Settings list request.
onSettingsUpdateRequest() (): (hook.Hook<SettingsUpdateRequestEvent | undefined>) OnSettingsUpdateRequest hook is triggered on each API Settings update request.
onSettingsReload() (): (hook.Hook<SettingsReloadEvent | undefined>) OnSettingsReload hook is triggered every time when the App.Settings() is being replaced with a new state.
onFileDownloadRequest() (...tags: string[]): (hook.TaggedHook<FileDownloadRequestEvent | undefined>) OnFileDownloadRequest hook is triggered before each API File download request.
onFileTokenRequest() (...tags: string[]): (hook.TaggedHook<FileTokenRequestEvent | undefined>) OnFileBeforeTokenRequest hook is triggered on each auth file token API request.
onRecordAuthRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthRequestEvent | undefined>) OnRecordAuthRequest hook is triggered on each successful API record authentication request (sign-in, token refresh, etc.).
onRecordAuthWithPasswordRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthWithPasswordRequestEvent | undefined>) OnRecordAuthWithPasswordRequest hook is triggered on each Record auth with password API request.
onRecordAuthWithOAuth2Request() (...tags: string[]): (hook.TaggedHook<RecordAuthWithOAuth2RequestEvent | undefined>) OnRecordAuthWithOAuth2Request hook is triggered on each Record OAuth2 sign-in/sign-up API request (after token exchange and before external provider linking).
onRecordAuthRefreshRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthRefreshRequestEvent | undefined>) OnRecordAuthRefreshRequest hook is triggered on each Record auth refresh API request (right before generating a new auth token).
onRecordRequestPasswordResetRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestPasswordResetRequestEvent | undefined>) OnRecordRequestPasswordResetRequest hook is triggered on each Record request password reset API request.
onRecordConfirmPasswordResetRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmPasswordResetRequestEvent | undefined>) OnRecordConfirmPasswordResetRequest hook is triggered on each Record confirm password reset API request.
onRecordRequestVerificationRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestVerificationRequestEvent | undefined>) OnRecordRequestVerificationRequest hook is triggered on each Record request verification API request.
onRecordConfirmVerificationRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmVerificationRequestEvent | undefined>) OnRecordConfirmVerificationRequest hook is triggered on each Record confirm verification API request.
onRecordRequestEmailChangeRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEmailChangeRequestEvent | undefined>) OnRecordRequestEmailChangeRequest hook is triggered on each Record request email change API request.
onRecordConfirmEmailChangeRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmEmailChangeRequestEvent | undefined>) OnRecordConfirmEmailChangeRequest hook is triggered on each Record confirm email change API request.
onRecordRequestOTPRequest() (...tags: string[]): (hook.TaggedHook<RecordCreateOTPRequestEvent | undefined>) OnRecordRequestOTPRequest hook is triggered on each Record request OTP API request.
onRecordAuthWithOTPRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthWithOTPRequestEvent | undefined>) OnRecordAuthWithOTPRequest hook is triggered on each Record auth with OTP API request.
onRecordsListRequest() (...tags: string[]): (hook.TaggedHook<RecordsListRequestEvent | undefined>) OnRecordsListRequest hook is triggered on each API Records list request.
onRecordViewRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>) OnRecordViewRequest hook is triggered on each API Record view request.
onRecordCreateRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>) OnRecordCreateRequest hook is triggered on each API Record create request.
onRecordUpdateRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>) OnRecordUpdateRequest hook is triggered on each API Record update request.
onRecordDeleteRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>) OnRecordDeleteRequest hook is triggered on each API Record delete request.
onCollectionsListRequest() (): (hook.Hook<CollectionsListRequestEvent | undefined>) OnCollectionsListRequest hook is triggered on each API Collections list request.
onCollectionViewRequest() (): (hook.Hook<CollectionRequestEvent | undefined>) OnCollectionViewRequest hook is triggered on each API Collection view request.
onCollectionCreateRequest() (): (hook.Hook<CollectionRequestEvent | undefined>) OnCollectionCreateRequest hook is triggered on each API Collection create request.
onCollectionUpdateRequest() (): (hook.Hook<CollectionRequestEvent | undefined>) OnCollectionUpdateRequest hook is triggered on each API Collection update request.
onCollectionDeleteRequest() (): (hook.Hook<CollectionRequestEvent | undefined>) OnCollectionDeleteRequest hook is triggered on each API Collection delete request.
onCollectionsImportRequest() (): (hook.Hook<CollectionsImportRequestEvent | undefined>) OnCollectionsBeforeImportRequest hook is triggered on each API collections import request.
onBatchRequest() (): (hook.Hook<BatchRequestEvent | undefined>) OnBatchRequest hook is triggered on each API batch request.

core.BaseApp

BaseApp implements CoreApp and defines the base PocketBase app structure.

Member Type
findAllAuthOriginsByRecord() (authRecord: Record): Array<(AuthOrigin | undefined)> FindAllAuthOriginsByRecord returns all AuthOrigin models linked to the provided auth record (in DESC order).
findAllAuthOriginsByCollection() (collection: Collection): Array<(AuthOrigin | undefined)> FindAllAuthOriginsByCollection returns all AuthOrigin models linked to the provided collection (in DESC order).
findAuthOriginById() (id: string): (AuthOrigin) FindAuthOriginById returns a single AuthOrigin model by its id.
findAuthOriginByRecordAndFingerprint() (authRecord: Record, fingerprint: string): (AuthOrigin) FindAuthOriginByRecordAndFingerprint returns a single AuthOrigin model by its authRecord relation and fingerprint.
deleteAllAuthOriginsByRecord() (authRecord: Record): void DeleteAllAuthOriginsByRecord deletes all AuthOrigin models associated with the provided record.
createBackup() (ctx: context.Context, name: string): void CreateBackup creates a new backup of the current app pb_data directory.
restoreBackup() (ctx: context.Context, name: string): void RestoreBackup restores the backup with the specified name and restarts the current running application process.
unsafeWithoutHooks() (): App UnsafeWithoutHooks returns a shallow copy of the current app WITHOUT any registered hooks.
logger() (): (slog.Logger) Logger returns the default app logger.
txInfo() (): (TxAppInfo) TxInfo returns the transaction associated with the current app instance (if any).
isTransactional() (): boolean IsTransactional checks if the current app instance is part of a transaction.
isBootstrapped() (): boolean IsBootstrapped checks if the application was initialized (aka. whether Bootstrap() was called).
bootstrap() (): void Bootstrap initializes the application (aka. create data dir, open db connections, load settings, etc.).
resetBootstrapState() (): void Deprecated: use ClearBootstrap.
clearBootstrap() (): void ClearBootstrap releases the initialized core app resources (closing db connections, stopping cron ticker, etc.).
db() (): dbx.Builder DB returns the default app data.db builder instance.
concurrentDB() (): dbx.Builder ConcurrentDB returns the concurrent app data.db builder instance.
nonconcurrentDB() (): dbx.Builder NonconcurrentDB returns the nonconcurrent app data.db builder instance.
auxDB() (): dbx.Builder AuxDB returns the app auxiliary.db builder instance.
auxConcurrentDB() (): dbx.Builder AuxConcurrentDB returns the concurrent app auxiliary.db builder instance.
auxNonconcurrentDB() (): dbx.Builder AuxNonconcurrentDB returns the nonconcurrent app auxiliary.db builder instance.
dataDir() (): string DataDir returns the app data directory path.
encryptionEnv() (): string EncryptionEnv returns the name of the app secret env key (currently used primarily for optional settings encryption but this may change in the future).
isDev() (): boolean IsDev returns whether the app is in dev mode.
settings() (): (Settings) Settings returns the loaded app settings.
store() (): (store.Store<string, any>) Store returns the app runtime store.
cron() (): (cron.Cron) Cron returns the app cron instance.
subscriptionsBroker() (): (subscriptions.Broker) SubscriptionsBroker returns the app realtime subscriptions broker instance.
newMailClient() (): mailer.Mailer NewMailClient creates and returns a new SMTP or Sendmail client based on the current app settings.
newFilesystem() (): (filesystem.System) NewFilesystem creates a new local or S3 filesystem instance for managing regular app files (ex. record uploads) based on the current app settings.
newBackupsFilesystem() (): (filesystem.System) NewBackupsFilesystem creates a new local or S3 filesystem instance for managing app backups based on the current app settings.
restart() (): void Restart restarts (aka. replaces) the current running application process.
runSystemMigrations() (): void RunSystemMigrations applies all new migrations registered in the core.systemMigrations list.
runAppMigrations() (): void RunAppMigrations applies all new migrations registered in the CoreAppMigrations list (PocketOne: or the app's own list, see AppMigrationsOf).
runAllMigrations() (): void RunAllMigrations applies all system and app migrations (aka. from both core.systemMigrations and CoreAppMigrations; PocketOne: or the app's own list, see AppMigrationsOf).
onBootstrap() (): (hook.Hook<BootstrapEvent | undefined>)
onBootstrapClear() (): (hook.Hook<BootstrapEvent | undefined>)
onServe() (): (hook.Hook<ServeEvent | undefined>)
onTerminate() (): (hook.Hook<TerminateEvent | undefined>)
onBackupCreate() (): (hook.Hook<BackupEvent | undefined>)
onBackupRestore() (): (hook.Hook<BackupEvent | undefined>)
onModelCreate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelCreateExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterCreateError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>)
onModelUpdate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelUpdateExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterUpdateError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>)
onModelValidate() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelDelete() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelDeleteExecute() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<ModelEvent | undefined>)
onModelAfterDeleteError() (...tags: string[]): (hook.TaggedHook<ModelErrorEvent | undefined>)
onRecordEnrich() (...tags: string[]): (hook.TaggedHook<RecordEnrichEvent | undefined>)
onRecordValidate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordCreate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordCreateExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterCreateError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>)
onRecordUpdate() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordUpdateExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterUpdateError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>)
onRecordDelete() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordDeleteExecute() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<RecordEvent | undefined>)
onRecordAfterDeleteError() (...tags: string[]): (hook.TaggedHook<RecordErrorEvent | undefined>)
onCollectionValidate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionCreate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionCreateExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterCreateSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterCreateError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>)
onCollectionUpdate() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionUpdateExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterUpdateSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterUpdateError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>)
onCollectionDelete() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionDeleteExecute() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterDeleteSuccess() (...tags: string[]): (hook.TaggedHook<CollectionEvent | undefined>)
onCollectionAfterDeleteError() (...tags: string[]): (hook.TaggedHook<CollectionErrorEvent | undefined>)
onMailerSend() (): (hook.Hook<MailerEvent | undefined>)
onMailerRecordPasswordResetSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>)
onMailerRecordVerificationSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>)
onMailerRecordEmailChangeSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>)
onMailerRecordOTPSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>)
onMailerRecordAuthAlertSend() (...tags: string[]): (hook.TaggedHook<MailerRecordEvent | undefined>)
onFilesystemCreate() (): (hook.Hook<FilesystemCreateEvent | undefined>) PocketOne: see App.onFilesystemCreate.
onRealtimeConnectRequest() (): (hook.Hook<RealtimeConnectRequestEvent | undefined>)
onRealtimeMessageSend() (): (hook.Hook<RealtimeMessageEvent | undefined>)
onRealtimeSubscribeRequest() (): (hook.Hook<RealtimeSubscribeRequestEvent | undefined>)
onSettingsListRequest() (): (hook.Hook<SettingsListRequestEvent | undefined>)
onSettingsUpdateRequest() (): (hook.Hook<SettingsUpdateRequestEvent | undefined>)
onSettingsReload() (): (hook.Hook<SettingsReloadEvent | undefined>)
onFileDownloadRequest() (...tags: string[]): (hook.TaggedHook<FileDownloadRequestEvent | undefined>)
onFileTokenRequest() (...tags: string[]): (hook.TaggedHook<FileTokenRequestEvent | undefined>)
onRecordAuthRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthRequestEvent | undefined>)
onRecordAuthWithPasswordRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthWithPasswordRequestEvent | undefined>)
onRecordAuthWithOAuth2Request() (...tags: string[]): (hook.TaggedHook<RecordAuthWithOAuth2RequestEvent | undefined>)
onRecordAuthRefreshRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthRefreshRequestEvent | undefined>)
onRecordRequestPasswordResetRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestPasswordResetRequestEvent | undefined>)
onRecordConfirmPasswordResetRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmPasswordResetRequestEvent | undefined>)
onRecordRequestVerificationRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestVerificationRequestEvent | undefined>)
onRecordConfirmVerificationRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmVerificationRequestEvent | undefined>)
onRecordRequestEmailChangeRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEmailChangeRequestEvent | undefined>)
onRecordConfirmEmailChangeRequest() (...tags: string[]): (hook.TaggedHook<RecordConfirmEmailChangeRequestEvent | undefined>)
onRecordRequestOTPRequest() (...tags: string[]): (hook.TaggedHook<RecordCreateOTPRequestEvent | undefined>)
onRecordAuthWithOTPRequest() (...tags: string[]): (hook.TaggedHook<RecordAuthWithOTPRequestEvent | undefined>)
onRecordsListRequest() (...tags: string[]): (hook.TaggedHook<RecordsListRequestEvent | undefined>)
onRecordViewRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>)
onRecordCreateRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>)
onRecordUpdateRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>)
onRecordDeleteRequest() (...tags: string[]): (hook.TaggedHook<RecordRequestEvent | undefined>)
onCollectionsListRequest() (): (hook.Hook<CollectionsListRequestEvent | undefined>)
onCollectionViewRequest() (): (hook.Hook<CollectionRequestEvent | undefined>)
onCollectionCreateRequest() (): (hook.Hook<CollectionRequestEvent | undefined>)
onCollectionUpdateRequest() (): (hook.Hook<CollectionRequestEvent | undefined>)
onCollectionDeleteRequest() (): (hook.Hook<CollectionRequestEvent | undefined>)
onCollectionsImportRequest() (): (hook.Hook<CollectionsImportRequestEvent | undefined>)
onBatchRequest() (): (hook.Hook<BatchRequestEvent | undefined>)
importCollectionsByMarshaledJSON() (rawSliceOfMaps: string|Array<number>, deleteMissing: boolean): void ImportCollectionsByMarshaledJSON is the same as ImportCollections but accept marshaled json array as import data (usually used for the autogenerated snapshots).
importCollections() (toImport: Array<{ [key: string]: any }>, deleteMissing: boolean): void ImportCollections imports the provided collections data in a single transaction.
collectionQuery() (): (dbx.SelectQuery) CollectionQuery returns a new Collection select query.
findAllCollections() (...collectionTypes: string[]): Array<(Collection | undefined)> FindCollections finds all collections by the given type(s).
reloadCachedCollections() (): void ReloadCachedCollections fetches all collections and caches them into the app store.
findCollectionByNameOrId() (nameOrId: string): (Collection) FindCollectionByNameOrId finds a single collection by its name (case insensitive) or id.
findCachedCollectionByNameOrId() (nameOrId: string): (Collection) FindCachedCollectionByNameOrId is similar to BaseApp.findCollectionByNameOrId but retrieves the Collection from the app cache instead of making a db call.
findCollectionReferences() (collection: Collection, ...excludeIds: string[]): { [key: string]: any } FindCollectionReferences returns information for all relation fields referencing the provided collection.
findCachedCollectionReferences() (collection: Collection, ...excludeIds: string[]): { [key: string]: any } FindCachedCollectionReferences is similar to BaseApp.findCollectionReferences but retrieves the Collection from the app cache instead of making a db call.
isCollectionNameUnique() (name: string, ...excludeIds: string[]): boolean IsCollectionNameUnique checks that there is no existing collection with the provided name (case insensitive!).
truncateCollection() (collection: Collection): void TruncateCollection deletes all records associated with the provided collection.
syncRecordTableSchema() (newCollection: Collection, oldCollection: Collection): void SyncRecordTableSchema compares the two provided collections and applies the necessary related record table changes.
modelQuery() (m: Model): (dbx.SelectQuery) ModelQuery creates a new preconfigured select data.db query with preset SELECT, FROM and other common fields based on the provided model.
auxModelQuery() (m: Model): (dbx.SelectQuery) AuxModelQuery creates a new preconfigured select auxiliary.db query with preset SELECT, FROM and other common fields based on the provided model.
delete() (model: Model): void Delete deletes the specified model from the regular app database.
deleteWithContext() (ctx: context.Context, model: Model): void Delete deletes the specified model from the regular app database (the context could be used to limit the query execution).
auxDelete() (model: Model): void AuxDelete deletes the specified model from the auxiliary database.
auxDeleteWithContext() (ctx: context.Context, model: Model): void AuxDeleteWithContext deletes the specified model from the auxiliary database (the context could be used to limit the query execution).
save() (model: Model): void Save validates and saves the specified model into the regular app database.
saveWithContext() (ctx: context.Context, model: Model): void SaveWithContext is the same as [App.Save()] but allows specifying a context to limit the db execution.
saveNoValidate() (model: Model): void SaveNoValidate saves the specified model into the regular app database without performing validations.
saveNoValidateWithContext() (ctx: context.Context, model: Model): void SaveNoValidateWithContext is the same as [App.SaveNoValidate()] but allows specifying a context to limit the db execution.
auxSave() (model: Model): void AuxSave validates and saves the specified model into the auxiliary app database.
auxSaveWithContext() (ctx: context.Context, model: Model): void AuxSaveWithContext is the same as [App.AuxSave()] but allows specifying a context to limit the db execution.
auxSaveNoValidate() (model: Model): void AuxSaveNoValidate saves the specified model into the auxiliary app database without performing validations.
auxSaveNoValidateWithContext() (ctx: context.Context, model: Model): void AuxSaveNoValidateWithContext is the same as [App.AuxSaveNoValidate()] but allows specifying a context to limit the db execution.
validate() (model: Model): void Validate triggers the OnModelValidate hook for the specified model.
validateWithContext() (ctx: context.Context, model: Model): void ValidateWithContext is the same as Validate but allows specifying the ModelEvent context.
tableColumns() (tableName: string): Array<string> TableColumns returns all column names of a single table by its name.
tableInfo() (tableName: string): Array<(TableInfoRow | undefined)> TableInfo returns the "table_info" pragma result for the specified table.
tableIndexes() (tableName: string): { [key: string]: any } TableIndexes returns a name grouped map with all non empty index of the specified table.
deleteTable() (dangerousTableName: string): void DeleteTable drops the specified table.
hasTable() (tableName: string): boolean HasTable checks if a table (or view) with the provided name exists (case insensitive). in the data.db.
auxHasTable() (tableName: string): boolean AuxHasTable checks if a table (or view) with the provided name exists (case insensitive) in the auixiliary.db.
vacuum() (): void Vacuum executes VACUUM on the data.db in order to reclaim unused data db disk space.
auxVacuum() (): void AuxVacuum executes VACUUM on the auxiliary.db in order to reclaim unused auxiliary db disk space.
runInTransaction() (fn: (txApp: App) => void): void RunInTransaction wraps fn into a transaction for the regular app database.
auxRunInTransaction() (fn: (txApp: App) => void): void AuxRunInTransaction wraps fn into a transaction for the auxiliary app database.
findAllExternalAuthsByRecord() (authRecord: Record): Array<(ExternalAuth | undefined)> FindAllExternalAuthsByRecord returns all ExternalAuth models linked to the provided auth record.
findAllExternalAuthsByCollection() (collection: Collection): Array<(ExternalAuth | undefined)> FindAllExternalAuthsByCollection returns all ExternalAuth models linked to the provided auth collection.
findFirstExternalAuthByExpr() (expr: dbx.Expression): (ExternalAuth) FindFirstExternalAuthByExpr returns the first available (the most recent created) ExternalAuth model that satisfies the non-nil expression.
deleteAllExternalAuthsByRecord() (authRecord: Record): void DeleteAllExternalAuthsByRecord deletes all ExternalAuth models associated with the provided record.
logQuery() (): (dbx.SelectQuery) LogQuery returns a new Log select query.
findLogById() (id: string): (Log) FindLogById finds a single Log entry by its id.
countLogs() (...optExprs: dbx.Expression[]): number CountLogs returns the total number of log entries.
logsStats() (expr: dbx.Expression): Array<(LogsStatsItem | undefined)> LogsStats returns hourly grouped logs statistics.
deleteOldLogs() (createdBefore: time.Time): void DeleteOldLogs delete all logs that are created before createdBefore.
findAllMFAsByRecord() (authRecord: Record): Array<(MFA | undefined)> FindAllMFAsByRecord returns all MFA models linked to the provided auth record.
findAllMFAsByCollection() (collection: Collection): Array<(MFA | undefined)> FindAllMFAsByCollection returns all MFA models linked to the provided collection.
findMFAById() (id: string): (MFA) FindMFAById returns a single MFA model by its id.
deleteAllMFAsByRecord() (authRecord: Record): void DeleteAllMFAsByRecord deletes all MFA models associated with the provided record.
deleteExpiredMFAs() (): void DeleteExpiredMFAs deletes the expired MFAs for all auth collections.
findAllOTPsByRecord() (authRecord: Record): Array<(OTP | undefined)> FindAllOTPsByRecord returns all OTP models linked to the provided auth record.
findAllOTPsByCollection() (collection: Collection): Array<(OTP | undefined)> FindAllOTPsByCollection returns all OTP models linked to the provided collection.
findOTPById() (id: string): (OTP) FindOTPById returns a single OTP model by its id.
deleteAllOTPsByRecord() (authRecord: Record): void DeleteAllOTPsByRecord deletes all OTP models associated with the provided record.
deleteExpiredOTPs() (): void DeleteExpiredOTPs deletes the expired OTPs for all auth collections.
recordQuery() (collectionModelOrIdentifier: any): (dbx.SelectQuery) RecordQuery returns a new Record select query from a collection model, id or name.
findRecordById() (collectionModelOrIdentifier: any, recordId: string, ...optFilters: ((q: dbx.SelectQuery) => void)[]): (Record) FindRecordById finds the Record model by its id.
findRecordsByIds() (collectionModelOrIdentifier: any, recordIds: Array<string>, ...optFilters: ((q: dbx.SelectQuery) => void)[]): Array<(Record | undefined)> FindRecordsByIds finds all records by the specified ids. If no records are found, returns an empty slice.
findAllRecords() (collectionModelOrIdentifier: any, ...exprs: dbx.Expression[]): Array<(Record | undefined)> FindAllRecords finds all records matching specified db expressions.
findFirstRecordByData() (collectionModelOrIdentifier: any, key: string, value: any): (Record) FindFirstRecordByData returns the first found record matching the provided key-value pair.
findRecordsByFilter() (collectionModelOrIdentifier: any, filter: string, sort: string, limit: number, offset: number, ...params: dbx.Params[]): Array<(Record | undefined)> FindRecordsByFilter returns limit number of records matching the provided string filter.
findFirstRecordByFilter() (collectionModelOrIdentifier: any, filter: string, ...params: dbx.Params[]): (Record) FindFirstRecordByFilter returns the first available record matching the provided filter (if any).
countRecords() (collectionModelOrIdentifier: any, ...optExprs: dbx.Expression[]): number CountRecords returns the total number of records in a collection.
findAuthRecordByToken() (token: string, ...validTypes: string[]): (Record) FindAuthRecordByToken finds the auth record associated with the provided JWT (auth, file, verifyEmail, changeEmail, passwordReset types).
findAuthRecordByEmail() (collectionModelOrIdentifier: any, email: string): (Record) FindAuthRecordByEmail finds the auth record associated with the provided email.
canAccessRecord() (record: Record, requestInfo: RequestInfo, accessRule: string): boolean CanAccessRecord checks if a record is allowed to be accessed by the specified requestInfo and accessRule.
expandRecord() (record: Record, expands: Array<string>, optFetchFunc: ExpandFetchFunc): { [key: string]: any } ExpandRecord expands the relations of a single Record model.
expandRecords() (records: Array<(Record | undefined)>, expands: Array<string>, optFetchFunc: ExpandFetchFunc): { [key: string]: any } ExpandRecords expands the relations of the provided Record models list.
reloadSettings() (): void ReloadSettings initializes and reloads the stored application settings.
deleteView() (dangerousViewName: string): void DeleteView drops the specified view name.
saveView() (dangerousViewName: string, dangerousSelectQuery: string): void SaveView creates (or updates already existing) persistent SQL view.
createViewFields() (dangerousSelectQuery: string): FieldsList CreateViewFields creates a new FieldsList from the provided select query.
dryRunView() (dangerousSelectQuery: string, sampleSize: number): (DryRunViewResult) DryRunView executes the provided query by creating a temporary view collection and returning a sample of the resulting query records (if valid).
findRecordByViewFile() (viewCollectionModelOrIdentifier: any, fileFieldName: string, filename: string): (Record) FindRecordByViewFile returns the original Record of the provided view collection file.

core.zipWriter

core.FilesManager

FilesManager defines an interface with common methods that files manager models should implement.

Member Type
baseFilesPath() (): string BaseFilesPath returns the storage dir path used by the interface instance.

core.DBConnectFunc

DBConnectFunc defines a database connection initialization function.

core.baseCollection

Has everything BaseModel has.

Member Type
listRule? string
viewRule? string
createRule? string
updateRule? string
deleteRule? string
rawOptions types.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.
name string
type string
fields FieldsList
indexes types.JSONArray<string>
created types.DateTime
updated types.DateTime
system boolean System prevents the collection rename, deletion and rules change. It is used primarily for internal purposes for collections like "_superusers", "_externalAuths", etc.

core.EmailTemplate

Member Type
subject string
body string
validate() (): void Validate makes EmailTemplate validatable by implementing validation.validatable interface.
resolve() (placeholders: { [key: string]: any }): [string, string] Resolve replaces the placeholder parameters in the current email template and returns its components as ready-to-use strings.

core.OAuth2KnownFields

Member Type
id string
name string
username string
avatarURL string

core.collectionValidator

core.optionsValidator

core.DBExporter

DBExporter defines an interface for custom DB data export. Usually used as part of App.save.

Member Type
dbExport() (app: App): { [key: string]: any } DBExport returns a key-value map with the data to be used when saving the struct in the database.

core.PreValidator

PreValidator defines an optional model interface for registering a function that will run BEFORE firing the validation hooks (see App.validateWithContext).

Member Type
preValidate() (ctx: context.Context, app: App): void PreValidate defines a function that runs BEFORE the validation hooks.

core.PostValidator

PostValidator defines an optional model interface for registering a function that will run AFTER executing the validation hooks (see App.validateWithContext).

Member Type
postValidate() (ctx: context.Context, app: App): void PostValidate defines a function that runs AFTER the successful execution of the validation hooks.

core.dualDBBuilder

note: expects both builder to use the same driver

Member Type
select() (...cols: string[]): (dbx.SelectQuery) Select implements the dbx.Builder.select interface method.
model() (data: { }): (dbx.ModelQuery) Model implements the dbx.Builder.model interface method.
generatePlaceholder() (i: number): string GeneratePlaceholder implements the dbx.Builder.generatePlaceholder interface method.
quote() (str: string): string Quote implements the dbx.Builder.quote interface method.
quoteSimpleTableName() (table: string): string QuoteSimpleTableName implements the dbx.Builder.quoteSimpleTableName interface method.
quoteSimpleColumnName() (col: string): string QuoteSimpleColumnName implements the dbx.Builder.quoteSimpleColumnName interface method.
queryBuilder() (): dbx.QueryBuilder QueryBuilder implements the dbx.Builder.queryBuilder interface method.
insert() (table: string, cols: dbx.Params): (dbx.Query) Insert implements the dbx.Builder.insert interface method.
upsert() (table: string, cols: dbx.Params, ...constraints: string[]): (dbx.Query) Upsert implements the dbx.Builder.upsert interface method.
update() (table: string, cols: dbx.Params, where: dbx.Expression): (dbx.Query) Update implements the dbx.Builder.update interface method.
delete() (table: string, where: dbx.Expression): (dbx.Query) Delete implements the dbx.Builder.delete interface method.
createTable() (table: string, cols: { [key: string]: any }, ...options: string[]): (dbx.Query) CreateTable implements the dbx.Builder.createTable interface method.
renameTable() (oldName: string, newName: string): (dbx.Query) RenameTable implements the dbx.Builder.renameTable interface method.
dropTable() (table: string): (dbx.Query) DropTable implements the dbx.Builder.dropTable interface method.
truncateTable() (table: string): (dbx.Query) TruncateTable implements the dbx.Builder.truncateTable interface method.
addColumn() (table: string, col: string, typ: string): (dbx.Query) AddColumn implements the dbx.Builder.addColumn interface method.
dropColumn() (table: string, col: string): (dbx.Query) DropColumn implements the dbx.Builder.dropColumn interface method.
renameColumn() (table: string, oldName: string, newName: string): (dbx.Query) RenameColumn implements the dbx.Builder.renameColumn interface method.
alterColumn() (table: string, col: string, typ: string): (dbx.Query) AlterColumn implements the dbx.Builder.alterColumn interface method.
addPrimaryKey() (table: string, name: string, ...cols: string[]): (dbx.Query) AddPrimaryKey implements the dbx.Builder.addPrimaryKey interface method.
dropPrimaryKey() (table: string, name: string): (dbx.Query) DropPrimaryKey implements the dbx.Builder.dropPrimaryKey interface method.
addForeignKey() (table: string, name: string, cols: Array<string>, refCols: Array<string>, refTable: string, ...options: string[]): (dbx.Query) AddForeignKey implements the dbx.Builder.addForeignKey interface method.
dropForeignKey() (table: string, name: string): (dbx.Query) DropForeignKey implements the dbx.Builder.dropForeignKey interface method.
createIndex() (table: string, name: string, ...cols: string[]): (dbx.Query) CreateIndex implements the dbx.Builder.createIndex interface method.
createUniqueIndex() (table: string, name: string, ...cols: string[]): (dbx.Query) CreateUniqueIndex implements the dbx.Builder.createUniqueIndex interface method.
dropIndex() (table: string, name: string): (dbx.Query) DropIndex implements the dbx.Builder.dropIndex interface method.
newQuery() (str: string): (dbx.Query) NewQuery implements the dbx.Builder.newQuery interface method by routing the SELECT queries to the concurrent builder instance.

core.TableInfoRow

Member Type
pk number the db:"pk" tag has special semantic so we cannot rename the original field without specifying a custom mapper
index number
name string
type string
notNull boolean
defaultValue sql.NullString

core.TxAppInfo

TxAppInfo represents an active transaction context associated to an existing app instance.

Member Type
onComplete() (fn: (txErr: Error) => void): void OnComplete registers the provided callback that will be invoked once the related transaction ends (either completes successfully or rollbacked with an error).

core.RequestInfo

RequestInfo defines a HTTP request data struct, usually used as part of the @request.* filter resolver.

The Query and Headers fields contains only the first value for each found entry.

Member Type
query { [key: string]: any }
headers { [key: string]: any }
body { [key: string]: any }
auth? Record
method string
context string
hasSuperuserAuth() (): boolean HasSuperuserAuth checks whether the current RequestInfo instance has superuser authentication loaded.
clone() (): (RequestInfo) Clone creates a new shallow copy of the current RequestInfo and its Auth record (if any).

core.InternalRequest

Member Type
body { [key: string]: any } note: for uploading files the value must be either *filesystem.File or []*filesystem.File
headers { [key: string]: any }
method string
url string
validate() (): void

core.HookTagger

Member Type
hookTags() (): Array<string>

core.UIExtension

Member Type
name string Name is the name of the extension. It is also used as path segment for the registered public extension endpoint (e.g. /_/extensions/{name}/*)
fs fs.FS FS is the extension file system.

core.MaxBodySizeCalculator

MaxBodySizeCalculator defines an optional field interface for specifying the max size of a field value.

Member Type
calculateMaxBodySize() (): number CalculateMaxBodySize returns the approximate max body size of a field value.

core.SetterFunc

core.SetterFinder

SetterFinder defines a field interface for registering custom field value setters.

Member Type
findSetter() (key: string): SetterFunc FindSetter returns a single field value setter function by performing pattern-like field matching using the specified key.

core.GetterFunc

core.GetterFinder

GetterFinder defines a field interface for registering custom field value getters.

Member Type
findGetter() (key: string): GetterFunc FindGetter returns a single field value getter function by performing pattern-like field matching using the specified key.

core.DriverValuer

DriverValuer defines a Field interface for exporting and formatting a field value for the database.

Member Type
driverValue() (record: Record): any DriverValue exports a single field value for persistence in the database.

core.MultiValuer

MultiValuer defines a field interface that every multi-valued (eg. with MaxSelect) field has.

Member Type
isMultiple() (): boolean IsMultiple checks whether the field is configured to support multiple or single values.

core.PasswordFieldValue

Member Type
lastError Error
hash string
plain string
validate() (pass: string): boolean

core.onlyFieldType

Member Type
type string

core.fieldWithType

Has everything Field has.

Member Type
type string
unmarshalJSON() (data: string|Array<number>): void

core.Migration

Member Type
up (txApp: App) => void
down (txApp: App) => void
file string
reapplyCondition (txApp: App, runner: MigrationsRunner, fileName: string) => boolean

core.MigrationsList

MigrationsList defines a list with migration definitions

Member Type
item() (index: number): (Migration) Item returns a single migration from the list by its index.
items() (): Array<(Migration | undefined)> Items returns the internal migrations list slice.
copy() (list: MigrationsList): void Copy copies all provided list migrations into the current one.
add() (m: Migration): void Add adds adds an existing migration definition to the list.
register() (up: (txApp: App) => void, down: (txApp: App) => void, ...optFilename: string[]): void Register adds new migration definition to the list.

core.MigrationsRunner

MigrationsRunner defines a simple struct for managing the execution of db migrations.

Member Type
run() (...args: string[]): void Run interactively executes the current runner with the provided args.
up() (): Array<string> Up executes all unapplied migrations for the provided runner.
down() (toRevertCount: number): Array<string> Down reverts the last toRevertCount applied migrations (in the order they were applied).
removeMissingAppliedMigrations() (): void RemoveMissingAppliedMigrations removes the db entries of all applied migrations that are not listed in the runner's migrations list.

core.ruleJoin

core.mapExtractor

Member Type
asMap() (): { [key: string]: any }

core.replaceWithExpression

replaceWithExpression defines a custom expression that will replace a placeholder identifier found in "old" with the result of "new".

Member Type
build() (db: dbx.DB, params: dbx.Params): string Build converts the expression into a SQL fragment.

core.runner

core.ExpandFetchFunc

ExpandFetchFunc defines the function that is used to fetch the expanded relation records.

core.settings

Member Type
superuserIPs Array<string> SuperuserIPs defines an optional list of the superuser allowed individual IPs and subnets (in CIDR notation).
smtp SMTPConfig
backups BackupsConfig
s3 S3Config
meta MetaConfig
rateLimits RateLimitsConfig
trustedProxy TrustedProxyConfig
batch BatchConfig
logs LogsConfig

core.RateLimitRule

Member Type
label string Label is the identifier of the current rule.
audience string Audience specifies the auth group the rule should apply for:
duration number Duration specifies the interval (in seconds) per which to reset the counted/accumulated rate limiter tokens.
maxRequests number MaxRequests is the max allowed number of requests per Duration.
validate() (): void Validate makes RateLimitRule validatable by implementing validation.validatable interface.
durationTime() (): time.Duration DurationTime returns the tag's Duration as time.duration.
string() (): string String returns a string representation of the rule.

core.DryRunViewResult

Member Type
fields FieldsList
sample Array<(Record | undefined)>

core.identifier

core.identifiersParser