Documentation ¶
Overview ¶
Package core is the backbone of PocketBase.
It defines the main PocketBase App interface and its base implementation.
Index ¶
- Constants
- type AdminAuthEvent
- type AdminCreateEvent
- type AdminDeleteEvent
- type AdminUpdateEvent
- type AdminViewEvent
- type AdminsListEvent
- type ApiErrorEvent
- type App
- type BaseApp
- func (app *BaseApp) Bootstrap() error
- func (app *BaseApp) Cache() *store.Store[any]
- func (app *BaseApp) DB() *dbx.DBdeprecated
- func (app *BaseApp) Dao() *daos.Dao
- func (app *BaseApp) DataDir() string
- func (app *BaseApp) EncryptionEnv() string
- func (app *BaseApp) IsBootstrapped() bool
- func (app *BaseApp) IsDebug() bool
- func (app *BaseApp) LogsDB() *dbx.DBdeprecated
- func (app *BaseApp) LogsDao() *daos.Dao
- func (app *BaseApp) NewFilesystem() (*filesystem.System, error)
- func (app *BaseApp) NewMailClient() mailer.Mailer
- func (app *BaseApp) OnAdminAfterCreateRequest() *hook.Hook[*AdminCreateEvent]
- func (app *BaseApp) OnAdminAfterDeleteRequest() *hook.Hook[*AdminDeleteEvent]
- func (app *BaseApp) OnAdminAfterUpdateRequest() *hook.Hook[*AdminUpdateEvent]
- func (app *BaseApp) OnAdminAuthRequest() *hook.Hook[*AdminAuthEvent]
- func (app *BaseApp) OnAdminBeforeCreateRequest() *hook.Hook[*AdminCreateEvent]
- func (app *BaseApp) OnAdminBeforeDeleteRequest() *hook.Hook[*AdminDeleteEvent]
- func (app *BaseApp) OnAdminBeforeUpdateRequest() *hook.Hook[*AdminUpdateEvent]
- func (app *BaseApp) OnAdminViewRequest() *hook.Hook[*AdminViewEvent]
- func (app *BaseApp) OnAdminsListRequest() *hook.Hook[*AdminsListEvent]
- func (app *BaseApp) OnAfterApiError() *hook.Hook[*ApiErrorEvent]
- func (app *BaseApp) OnAfterBootstrap() *hook.Hook[*BootstrapEvent]
- func (app *BaseApp) OnBeforeApiError() *hook.Hook[*ApiErrorEvent]
- func (app *BaseApp) OnBeforeBootstrap() *hook.Hook[*BootstrapEvent]
- func (app *BaseApp) OnBeforeServe() *hook.Hook[*ServeEvent]
- func (app *BaseApp) OnCollectionAfterCreateRequest() *hook.Hook[*CollectionCreateEvent]
- func (app *BaseApp) OnCollectionAfterDeleteRequest() *hook.Hook[*CollectionDeleteEvent]
- func (app *BaseApp) OnCollectionAfterUpdateRequest() *hook.Hook[*CollectionUpdateEvent]
- func (app *BaseApp) OnCollectionBeforeCreateRequest() *hook.Hook[*CollectionCreateEvent]
- func (app *BaseApp) OnCollectionBeforeDeleteRequest() *hook.Hook[*CollectionDeleteEvent]
- func (app *BaseApp) OnCollectionBeforeUpdateRequest() *hook.Hook[*CollectionUpdateEvent]
- func (app *BaseApp) OnCollectionViewRequest() *hook.Hook[*CollectionViewEvent]
- func (app *BaseApp) OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImportEvent]
- func (app *BaseApp) OnCollectionsBeforeImportRequest() *hook.Hook[*CollectionsImportEvent]
- func (app *BaseApp) OnCollectionsListRequest() *hook.Hook[*CollectionsListEvent]
- func (app *BaseApp) OnFileDownloadRequest() *hook.Hook[*FileDownloadEvent]
- func (app *BaseApp) OnMailerAfterAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]
- func (app *BaseApp) OnMailerAfterRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnMailerAfterRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnMailerAfterRecordVerificationSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnMailerBeforeAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]
- func (app *BaseApp) OnMailerBeforeRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnMailerBeforeRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnMailerBeforeRecordVerificationSend() *hook.Hook[*MailerRecordEvent]
- func (app *BaseApp) OnModelAfterCreate() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnModelAfterDelete() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnModelAfterUpdate() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnModelBeforeCreate() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnModelBeforeDelete() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnModelBeforeUpdate() *hook.Hook[*ModelEvent]
- func (app *BaseApp) OnRealtimeAfterMessageSend() *hook.Hook[*RealtimeMessageEvent]
- func (app *BaseApp) OnRealtimeAfterSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]
- func (app *BaseApp) OnRealtimeBeforeMessageSend() *hook.Hook[*RealtimeMessageEvent]
- func (app *BaseApp) OnRealtimeBeforeSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]
- func (app *BaseApp) OnRealtimeConnectRequest() *hook.Hook[*RealtimeConnectEvent]
- func (app *BaseApp) OnRealtimeDisconnectRequest() *hook.Hook[*RealtimeDisconnectEvent]
- func (app *BaseApp) OnRecordAfterConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent]
- func (app *BaseApp) OnRecordAfterConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent]
- func (app *BaseApp) OnRecordAfterConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent]
- func (app *BaseApp) OnRecordAfterCreateRequest() *hook.Hook[*RecordCreateEvent]
- func (app *BaseApp) OnRecordAfterDeleteRequest() *hook.Hook[*RecordDeleteEvent]
- func (app *BaseApp) OnRecordAfterRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent]
- func (app *BaseApp) OnRecordAfterRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent]
- func (app *BaseApp) OnRecordAfterRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent]
- func (app *BaseApp) OnRecordAfterUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent]
- func (app *BaseApp) OnRecordAfterUpdateRequest() *hook.Hook[*RecordUpdateEvent]
- func (app *BaseApp) OnRecordAuthRequest() *hook.Hook[*RecordAuthEvent]
- func (app *BaseApp) OnRecordBeforeConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent]
- func (app *BaseApp) OnRecordBeforeConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent]
- func (app *BaseApp) OnRecordBeforeConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent]
- func (app *BaseApp) OnRecordBeforeCreateRequest() *hook.Hook[*RecordCreateEvent]
- func (app *BaseApp) OnRecordBeforeDeleteRequest() *hook.Hook[*RecordDeleteEvent]
- func (app *BaseApp) OnRecordBeforeRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent]
- func (app *BaseApp) OnRecordBeforeRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent]
- func (app *BaseApp) OnRecordBeforeRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent]
- func (app *BaseApp) OnRecordBeforeUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent]
- func (app *BaseApp) OnRecordBeforeUpdateRequest() *hook.Hook[*RecordUpdateEvent]
- func (app *BaseApp) OnRecordListExternalAuthsRequest() *hook.Hook[*RecordListExternalAuthsEvent]
- func (app *BaseApp) OnRecordViewRequest() *hook.Hook[*RecordViewEvent]
- func (app *BaseApp) OnRecordsListRequest() *hook.Hook[*RecordsListEvent]
- func (app *BaseApp) OnSettingsAfterUpdateRequest() *hook.Hook[*SettingsUpdateEvent]
- func (app *BaseApp) OnSettingsBeforeUpdateRequest() *hook.Hook[*SettingsUpdateEvent]
- func (app *BaseApp) OnSettingsListRequest() *hook.Hook[*SettingsListEvent]
- func (app *BaseApp) RefreshSettings() error
- func (app *BaseApp) ResetBootstrapState() error
- func (app *BaseApp) Settings() *settings.Settings
- func (app *BaseApp) SubscriptionsBroker() *subscriptions.Broker
- type BaseAppConfig
- type BootstrapEvent
- type CollectionCreateEvent
- type CollectionDeleteEvent
- type CollectionUpdateEvent
- type CollectionViewEvent
- type CollectionsImportEvent
- type CollectionsListEvent
- type FileDownloadEvent
- type MailerAdminEvent
- type MailerRecordEvent
- type ModelEvent
- type RealtimeConnectEvent
- type RealtimeDisconnectEvent
- type RealtimeMessageEvent
- type RealtimeSubscribeEvent
- type RecordAuthEvent
- type RecordConfirmEmailChangeEvent
- type RecordConfirmPasswordResetEvent
- type RecordConfirmVerificationEvent
- type RecordCreateEvent
- type RecordDeleteEvent
- type RecordListExternalAuthsEvent
- type RecordRequestEmailChangeEvent
- type RecordRequestPasswordResetEvent
- type RecordRequestVerificationEvent
- type RecordUnlinkExternalAuthEvent
- type RecordUpdateEvent
- type RecordViewEvent
- type RecordsListEvent
- type ServeEvent
- type SettingsListEvent
- type SettingsUpdateEvent
Constants ¶
const ( DefaultDataMaxOpenConns int = 100 DefaultDataMaxIdleConns int = 20 DefaultLogsMaxOpenConns int = 10 DefaultLogsMaxIdleConns int = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminAuthEvent ¶
type AdminCreateEvent ¶
type AdminDeleteEvent ¶
type AdminUpdateEvent ¶
type AdminViewEvent ¶
type AdminsListEvent ¶
type ApiErrorEvent ¶
type ApiErrorEvent struct { HttpContext echo.Context Error error }
type App ¶
type App interface { // Deprecated: // This method may get removed in the near future. // It is recommended to access the logs db instance from app.Dao().DB() or // if you want more flexibility - app.Dao().ConcurrentDB() and app.Dao().NonconcurrentDB(). // // DB returns the default app database instance. DB() *dbx.DB // Dao returns the default app Dao instance. // // This Dao could operate only on the tables and models // associated with the default app database. For example, // trying to access the request logs table will result in error. Dao() *daos.Dao // Deprecated: // This method may get removed in the near future. // It is recommended to access the logs db instance from app.LogsDao().DB() or // if you want more flexibility - app.LogsDao().ConcurrentDB() and app.LogsDao().NonconcurrentDB(). // // LogsDB returns the app logs database instance. LogsDB() *dbx.DB // LogsDao returns the app logs Dao instance. // // This Dao could operate only on the tables and models // associated with the logs database. For example, trying to access // the users table from LogsDao will result in error. LogsDao() *daos.Dao // DataDir returns the app data directory path. DataDir() string // EncryptionEnv returns the name of the app secret env key // (used for settings encryption). EncryptionEnv() string // IsDebug returns whether the app is in debug mode // (showing more detailed error logs, executed sql statements, etc.). IsDebug() bool // Settings returns the loaded app settings. Settings() *settings.Settings // Cache returns the app internal cache store. Cache() *store.Store[any] // SubscriptionsBroker returns the app realtime subscriptions broker instance. SubscriptionsBroker() *subscriptions.Broker // NewMailClient creates and returns a configured app mail client. NewMailClient() mailer.Mailer // NewFilesystem creates and returns a configured filesystem.System instance. // // NB! Make sure to call `Close()` on the returned result // after you are done working with it. NewFilesystem() (*filesystem.System, error) // RefreshSettings reinitializes and reloads the stored application settings. RefreshSettings() error // IsBootstrapped checks if the application was initialized // (aka. whether Bootstrap() was called). IsBootstrapped() bool // Bootstrap takes care for initializing the application // (open db connections, load settings, etc.). // // It will call ResetBootstrapState() if the application was already bootstrapped. Bootstrap() error // ResetBootstrapState takes care for releasing initialized app resources // (eg. closing db connections). ResetBootstrapState() error // OnBeforeBootstrap hook is triggered before initializing the base // application resources (eg. before db open and initial settings load). OnBeforeBootstrap() *hook.Hook[*BootstrapEvent] // OnAfterBootstrap hook is triggered after initializing the base // application resources (eg. after db open and initial settings load). OnAfterBootstrap() *hook.Hook[*BootstrapEvent] // OnBeforeServe hook is triggered before serving the internal router (echo), // allowing you to adjust its options and attach new routes. OnBeforeServe() *hook.Hook[*ServeEvent] // OnBeforeApiError hook is triggered right before sending an error API // response to the client, allowing you to further modify the error data // or to return a completely different API response (using [hook.StopPropagation]). OnBeforeApiError() *hook.Hook[*ApiErrorEvent] // OnAfterApiError hook is triggered right after sending an error API // response to the client. // It could be used to log the final API error in external services. OnAfterApiError() *hook.Hook[*ApiErrorEvent] // OnModelBeforeCreate hook is triggered before inserting a new // entry in the DB, allowing you to modify or validate the stored data. OnModelBeforeCreate() *hook.Hook[*ModelEvent] // OnModelAfterCreate hook is triggered after successfully // inserting a new entry in the DB. OnModelAfterCreate() *hook.Hook[*ModelEvent] // OnModelBeforeUpdate hook is triggered before updating existing // entry in the DB, allowing you to modify or validate the stored data. OnModelBeforeUpdate() *hook.Hook[*ModelEvent] // OnModelAfterUpdate hook is triggered after successfully updating // existing entry in the DB. OnModelAfterUpdate() *hook.Hook[*ModelEvent] // OnModelBeforeDelete hook is triggered before deleting an // existing entry from the DB. OnModelBeforeDelete() *hook.Hook[*ModelEvent] // OnModelAfterDelete is triggered after successfully deleting an // existing entry from the DB. OnModelAfterDelete() *hook.Hook[*ModelEvent] // OnMailerBeforeAdminResetPasswordSend hook is triggered right before // sending a password reset email to an admin. // // Could be used to send your own custom email template if // [hook.StopPropagation] is returned in one of its listeners. OnMailerBeforeAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent] // OnMailerAfterAdminResetPasswordSend hook is triggered after // admin password reset email was successfully sent. OnMailerAfterAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent] // OnMailerBeforeRecordResetPasswordSend hook is triggered right before // sending a password reset email to an auth record. // // Could be used to send your own custom email template if // [hook.StopPropagation] is returned in one of its listeners. OnMailerBeforeRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent] // OnMailerAfterRecordResetPasswordSend hook is triggered after // an auth record password reset email was successfully sent. OnMailerAfterRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent] // OnMailerBeforeRecordVerificationSend hook is triggered right before // sending a verification email to an auth record. // // Could be used to send your own custom email template if // [hook.StopPropagation] is returned in one of its listeners. OnMailerBeforeRecordVerificationSend() *hook.Hook[*MailerRecordEvent] // OnMailerAfterRecordVerificationSend hook is triggered after a // verification email was successfully sent to an auth record. OnMailerAfterRecordVerificationSend() *hook.Hook[*MailerRecordEvent] // OnMailerBeforeRecordChangeEmailSend hook is triggered right before // sending a confirmation new address email to an auth record. // // Could be used to send your own custom email template if // [hook.StopPropagation] is returned in one of its listeners. OnMailerBeforeRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent] // OnMailerAfterRecordChangeEmailSend hook is triggered after a // verification email was successfully sent to an auth record. OnMailerAfterRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent] // OnRealtimeConnectRequest hook is triggered right before establishing // the SSE client connection. OnRealtimeConnectRequest() *hook.Hook[*RealtimeConnectEvent] // OnRealtimeDisconnectRequest hook is triggered on disconnected/interrupted // SSE client connection. OnRealtimeDisconnectRequest() *hook.Hook[*RealtimeDisconnectEvent] // OnRealtimeBeforeMessage hook is triggered right before sending // an SSE message to a client. // // Returning [hook.StopPropagation] will prevent sending the message. // Returning any other non-nil error will close the realtime connection. OnRealtimeBeforeMessageSend() *hook.Hook[*RealtimeMessageEvent] // OnRealtimeBeforeMessage hook is triggered right after sending // an SSE message to a client. OnRealtimeAfterMessageSend() *hook.Hook[*RealtimeMessageEvent] // OnRealtimeBeforeSubscribeRequest hook is triggered before changing // the client subscriptions, allowing you to further validate and // modify the submitted change. OnRealtimeBeforeSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent] // OnRealtimeAfterSubscribeRequest hook is triggered after the client // subscriptions were successfully changed. OnRealtimeAfterSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent] // OnSettingsListRequest hook is triggered on each successful // API Settings list request. // // Could be used to validate or modify the response before // returning it to the client. OnSettingsListRequest() *hook.Hook[*SettingsListEvent] // OnSettingsBeforeUpdateRequest hook is triggered before each API // Settings update request (after request data load and before settings persistence). // // Could be used to additionally validate the request data or // implement completely different persistence behavior // (returning [hook.StopPropagation]). OnSettingsBeforeUpdateRequest() *hook.Hook[*SettingsUpdateEvent] // OnSettingsAfterUpdateRequest hook is triggered after each // successful API Settings update request. OnSettingsAfterUpdateRequest() *hook.Hook[*SettingsUpdateEvent] // OnFileDownloadRequest hook is triggered before each API File download request. // // Could be used to validate or modify the file response before // returning it to the client. OnFileDownloadRequest() *hook.Hook[*FileDownloadEvent] // OnAdminsListRequest hook is triggered on each API Admins list request. // // Could be used to validate or modify the response before returning it to the client. OnAdminsListRequest() *hook.Hook[*AdminsListEvent] // OnAdminViewRequest hook is triggered on each API Admin view request. // // Could be used to validate or modify the response before returning it to the client. OnAdminViewRequest() *hook.Hook[*AdminViewEvent] // OnAdminBeforeCreateRequest hook is triggered before each API // Admin create request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnAdminBeforeCreateRequest() *hook.Hook[*AdminCreateEvent] // OnAdminAfterCreateRequest hook is triggered after each // successful API Admin create request. OnAdminAfterCreateRequest() *hook.Hook[*AdminCreateEvent] // OnAdminBeforeUpdateRequest hook is triggered before each API // Admin update request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnAdminBeforeUpdateRequest() *hook.Hook[*AdminUpdateEvent] // OnAdminAfterUpdateRequest hook is triggered after each // successful API Admin update request. OnAdminAfterUpdateRequest() *hook.Hook[*AdminUpdateEvent] // OnAdminBeforeDeleteRequest hook is triggered before each API // Admin delete request (after model load and before actual deletion). // // Could be used to additionally validate the request data or implement // completely different delete behavior (returning [hook.StopPropagation]). OnAdminBeforeDeleteRequest() *hook.Hook[*AdminDeleteEvent] // OnAdminAfterDeleteRequest hook is triggered after each // successful API Admin delete request. OnAdminAfterDeleteRequest() *hook.Hook[*AdminDeleteEvent] // OnAdminAuthRequest hook is triggered on each successful API Admin // authentication request (sign-in, token refresh, etc.). // // Could be used to additionally validate or modify the // authenticated admin data and token. OnAdminAuthRequest() *hook.Hook[*AdminAuthEvent] // OnRecordAuthRequest hook is triggered on each successful API // record authentication request (sign-in, token refresh, etc.). // // Could be used to additionally validate or modify the authenticated // record data and token. OnRecordAuthRequest() *hook.Hook[*RecordAuthEvent] // OnRecordBeforeRequestPasswordResetRequest hook is triggered before each Record // request password reset API request (after request data load and before sending the reset email). // // Could be used to additionally validate the request data or implement // completely different password reset behavior (returning [hook.StopPropagation]). OnRecordBeforeRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent] // OnRecordAfterRequestPasswordResetRequest hook is triggered after each // successful request password reset API request. OnRecordAfterRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent] // OnRecordBeforeConfirmPasswordResetRequest hook is triggered before each Record // confirm password reset API request (after request data load and before persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnRecordBeforeConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent] // OnRecordAfterConfirmPasswordResetRequest hook is triggered after each // successful confirm password reset API request. OnRecordAfterConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent] // OnRecordBeforeRequestVerificationRequest hook is triggered before each Record // request verification API request (after request data load and before sending the verification email). // // Could be used to additionally validate the loaded request data or implement // completely different verification behavior (returning [hook.StopPropagation]). OnRecordBeforeRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent] // OnRecordAfterRequestVerificationRequest hook is triggered after each // successful request verification API request. OnRecordAfterRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent] // OnRecordBeforeConfirmVerificationRequest hook is triggered before each Record // confirm verification API request (after request data load and before persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnRecordBeforeConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent] // OnRecordAfterConfirmVerificationRequest hook is triggered after each // successful confirm verification API request. OnRecordAfterConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent] // OnRecordBeforeRequestEmailChangeRequest hook is triggered before each Record request email change API request // (after request data load and before sending the email link to confirm the change). // // Could be used to additionally validate the request data or implement // completely different request email change behavior (returning [hook.StopPropagation]). OnRecordBeforeRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent] // OnRecordAfterRequestEmailChangeRequest hook is triggered after each // successful request email change API request. OnRecordAfterRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent] // OnRecordBeforeConfirmEmailChangeRequest hook is triggered before each Record // confirm email change API request (after request data load and before persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnRecordBeforeConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent] // OnRecordAfterConfirmEmailChangeRequest hook is triggered after each // successful confirm email change API request. OnRecordAfterConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent] // OnRecordListExternalAuthsRequest hook is triggered on each API record external auths list request. // // Could be used to validate or modify the response before returning it to the client. OnRecordListExternalAuthsRequest() *hook.Hook[*RecordListExternalAuthsEvent] // OnRecordBeforeUnlinkExternalAuthRequest hook is triggered before each API record // external auth unlink request (after models load and before the actual relation deletion). // // Could be used to additionally validate the request data or implement // completely different delete behavior (returning [hook.StopPropagation]). OnRecordBeforeUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent] // OnRecordAfterUnlinkExternalAuthRequest hook is triggered after each // successful API record external auth unlink request. OnRecordAfterUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent] // OnRecordsListRequest hook is triggered on each API Records list request. // // Could be used to validate or modify the response before returning it to the client. OnRecordsListRequest() *hook.Hook[*RecordsListEvent] // OnRecordViewRequest hook is triggered on each API Record view request. // // Could be used to validate or modify the response before returning it to the client. OnRecordViewRequest() *hook.Hook[*RecordViewEvent] // OnRecordBeforeCreateRequest hook is triggered before each API Record // create request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnRecordBeforeCreateRequest() *hook.Hook[*RecordCreateEvent] // OnRecordAfterCreateRequest hook is triggered after each // successful API Record create request. OnRecordAfterCreateRequest() *hook.Hook[*RecordCreateEvent] // OnRecordBeforeUpdateRequest hook is triggered before each API Record // update request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnRecordBeforeUpdateRequest() *hook.Hook[*RecordUpdateEvent] // OnRecordAfterUpdateRequest hook is triggered after each // successful API Record update request. OnRecordAfterUpdateRequest() *hook.Hook[*RecordUpdateEvent] // OnRecordBeforeDeleteRequest hook is triggered before each API Record // delete request (after model load and before actual deletion). // // Could be used to additionally validate the request data or implement // completely different delete behavior (returning [hook.StopPropagation]). OnRecordBeforeDeleteRequest() *hook.Hook[*RecordDeleteEvent] // OnRecordAfterDeleteRequest hook is triggered after each // successful API Record delete request. OnRecordAfterDeleteRequest() *hook.Hook[*RecordDeleteEvent] // OnCollectionsListRequest hook is triggered on each API Collections list request. // // Could be used to validate or modify the response before returning it to the client. OnCollectionsListRequest() *hook.Hook[*CollectionsListEvent] // OnCollectionViewRequest hook is triggered on each API Collection view request. // // Could be used to validate or modify the response before returning it to the client. OnCollectionViewRequest() *hook.Hook[*CollectionViewEvent] // OnCollectionBeforeCreateRequest hook is triggered before each API Collection // create request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnCollectionBeforeCreateRequest() *hook.Hook[*CollectionCreateEvent] // OnCollectionAfterCreateRequest hook is triggered after each // successful API Collection create request. OnCollectionAfterCreateRequest() *hook.Hook[*CollectionCreateEvent] // OnCollectionBeforeUpdateRequest hook is triggered before each API Collection // update request (after request data load and before model persistence). // // Could be used to additionally validate the request data or implement // completely different persistence behavior (returning [hook.StopPropagation]). OnCollectionBeforeUpdateRequest() *hook.Hook[*CollectionUpdateEvent] // OnCollectionAfterUpdateRequest hook is triggered after each // successful API Collection update request. OnCollectionAfterUpdateRequest() *hook.Hook[*CollectionUpdateEvent] // OnCollectionBeforeDeleteRequest hook is triggered before each API // Collection delete request (after model load and before actual deletion). // // Could be used to additionally validate the request data or implement // completely different delete behavior (returning [hook.StopPropagation]). OnCollectionBeforeDeleteRequest() *hook.Hook[*CollectionDeleteEvent] // OnCollectionAfterDeleteRequest hook is triggered after each // successful API Collection delete request. OnCollectionAfterDeleteRequest() *hook.Hook[*CollectionDeleteEvent] // OnCollectionsBeforeImportRequest hook is triggered before each API // collections import request (after request data load and before the actual import). // // Could be used to additionally validate the imported collections or // to implement completely different import behavior (returning [hook.StopPropagation]). OnCollectionsBeforeImportRequest() *hook.Hook[*CollectionsImportEvent] // OnCollectionsAfterImportRequest hook is triggered after each // successful API collections import request. OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImportEvent] }
App defines the main PocketBase app interface.
type BaseApp ¶
type BaseApp struct {
// contains filtered or unexported fields
}
BaseApp implements core.App and defines the base PocketBase app structure.
func NewBaseApp ¶
func NewBaseApp(config *BaseAppConfig) *BaseApp
NewBaseApp creates and returns a new BaseApp instance configured with the provided arguments.
To initialize the app, you need to call `app.Bootstrap()`.
func (*BaseApp) Bootstrap ¶
Bootstrap initializes the application (aka. create data dir, open db connections, load settings, etc.).
It will call ResetBootstrapState() if the application was already bootstrapped.
func (*BaseApp) DB
deprecated
func (*BaseApp) EncryptionEnv ¶
EncryptionEnv returns the name of the app secret env key (used for settings encryption).
func (*BaseApp) IsBootstrapped ¶
IsBootstrapped checks if the application was initialized (aka. whether Bootstrap() was called).
func (*BaseApp) IsDebug ¶
IsDebug returns whether the app is in debug mode (showing more detailed error logs, executed sql statements, etc.).
func (*BaseApp) LogsDB
deprecated
Deprecated: This method may get removed in the near future. It is recommended to access the logs db instance from app.LogsDao().DB() or if you want more flexibility - app.LogsDao().ConcurrentDB() and app.LogsDao().NonconcurrentDB().
LogsDB returns the app logs database instance.
func (*BaseApp) NewFilesystem ¶
func (app *BaseApp) NewFilesystem() (*filesystem.System, error)
NewFilesystem creates a new local or S3 filesystem instance based on the current app settings.
NB! Make sure to call `Close()` on the returned result after you are done working with it.
func (*BaseApp) NewMailClient ¶
NewMailClient creates and returns a new SMTP or Sendmail client based on the current app settings.
func (*BaseApp) OnAdminAfterCreateRequest ¶
func (app *BaseApp) OnAdminAfterCreateRequest() *hook.Hook[*AdminCreateEvent]
func (*BaseApp) OnAdminAfterDeleteRequest ¶
func (app *BaseApp) OnAdminAfterDeleteRequest() *hook.Hook[*AdminDeleteEvent]
func (*BaseApp) OnAdminAfterUpdateRequest ¶
func (app *BaseApp) OnAdminAfterUpdateRequest() *hook.Hook[*AdminUpdateEvent]
func (*BaseApp) OnAdminAuthRequest ¶
func (app *BaseApp) OnAdminAuthRequest() *hook.Hook[*AdminAuthEvent]
func (*BaseApp) OnAdminBeforeCreateRequest ¶
func (app *BaseApp) OnAdminBeforeCreateRequest() *hook.Hook[*AdminCreateEvent]
func (*BaseApp) OnAdminBeforeDeleteRequest ¶
func (app *BaseApp) OnAdminBeforeDeleteRequest() *hook.Hook[*AdminDeleteEvent]
func (*BaseApp) OnAdminBeforeUpdateRequest ¶
func (app *BaseApp) OnAdminBeforeUpdateRequest() *hook.Hook[*AdminUpdateEvent]
func (*BaseApp) OnAdminViewRequest ¶
func (app *BaseApp) OnAdminViewRequest() *hook.Hook[*AdminViewEvent]
func (*BaseApp) OnAdminsListRequest ¶
func (app *BaseApp) OnAdminsListRequest() *hook.Hook[*AdminsListEvent]
func (*BaseApp) OnAfterApiError ¶
func (app *BaseApp) OnAfterApiError() *hook.Hook[*ApiErrorEvent]
func (*BaseApp) OnAfterBootstrap ¶
func (app *BaseApp) OnAfterBootstrap() *hook.Hook[*BootstrapEvent]
func (*BaseApp) OnBeforeApiError ¶
func (app *BaseApp) OnBeforeApiError() *hook.Hook[*ApiErrorEvent]
func (*BaseApp) OnBeforeBootstrap ¶
func (app *BaseApp) OnBeforeBootstrap() *hook.Hook[*BootstrapEvent]
func (*BaseApp) OnBeforeServe ¶
func (app *BaseApp) OnBeforeServe() *hook.Hook[*ServeEvent]
func (*BaseApp) OnCollectionAfterCreateRequest ¶
func (app *BaseApp) OnCollectionAfterCreateRequest() *hook.Hook[*CollectionCreateEvent]
func (*BaseApp) OnCollectionAfterDeleteRequest ¶
func (app *BaseApp) OnCollectionAfterDeleteRequest() *hook.Hook[*CollectionDeleteEvent]
func (*BaseApp) OnCollectionAfterUpdateRequest ¶
func (app *BaseApp) OnCollectionAfterUpdateRequest() *hook.Hook[*CollectionUpdateEvent]
func (*BaseApp) OnCollectionBeforeCreateRequest ¶
func (app *BaseApp) OnCollectionBeforeCreateRequest() *hook.Hook[*CollectionCreateEvent]
func (*BaseApp) OnCollectionBeforeDeleteRequest ¶
func (app *BaseApp) OnCollectionBeforeDeleteRequest() *hook.Hook[*CollectionDeleteEvent]
func (*BaseApp) OnCollectionBeforeUpdateRequest ¶
func (app *BaseApp) OnCollectionBeforeUpdateRequest() *hook.Hook[*CollectionUpdateEvent]
func (*BaseApp) OnCollectionViewRequest ¶
func (app *BaseApp) OnCollectionViewRequest() *hook.Hook[*CollectionViewEvent]
func (*BaseApp) OnCollectionsAfterImportRequest ¶
func (app *BaseApp) OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImportEvent]
func (*BaseApp) OnCollectionsBeforeImportRequest ¶
func (app *BaseApp) OnCollectionsBeforeImportRequest() *hook.Hook[*CollectionsImportEvent]
func (*BaseApp) OnCollectionsListRequest ¶
func (app *BaseApp) OnCollectionsListRequest() *hook.Hook[*CollectionsListEvent]
func (*BaseApp) OnFileDownloadRequest ¶
func (app *BaseApp) OnFileDownloadRequest() *hook.Hook[*FileDownloadEvent]
func (*BaseApp) OnMailerAfterAdminResetPasswordSend ¶
func (app *BaseApp) OnMailerAfterAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]
func (*BaseApp) OnMailerAfterRecordChangeEmailSend ¶
func (app *BaseApp) OnMailerAfterRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnMailerAfterRecordResetPasswordSend ¶
func (app *BaseApp) OnMailerAfterRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnMailerAfterRecordVerificationSend ¶
func (app *BaseApp) OnMailerAfterRecordVerificationSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnMailerBeforeAdminResetPasswordSend ¶
func (app *BaseApp) OnMailerBeforeAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]
func (*BaseApp) OnMailerBeforeRecordChangeEmailSend ¶
func (app *BaseApp) OnMailerBeforeRecordChangeEmailSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnMailerBeforeRecordResetPasswordSend ¶
func (app *BaseApp) OnMailerBeforeRecordResetPasswordSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnMailerBeforeRecordVerificationSend ¶
func (app *BaseApp) OnMailerBeforeRecordVerificationSend() *hook.Hook[*MailerRecordEvent]
func (*BaseApp) OnModelAfterCreate ¶
func (app *BaseApp) OnModelAfterCreate() *hook.Hook[*ModelEvent]
func (*BaseApp) OnModelAfterDelete ¶
func (app *BaseApp) OnModelAfterDelete() *hook.Hook[*ModelEvent]
func (*BaseApp) OnModelAfterUpdate ¶
func (app *BaseApp) OnModelAfterUpdate() *hook.Hook[*ModelEvent]
func (*BaseApp) OnModelBeforeCreate ¶
func (app *BaseApp) OnModelBeforeCreate() *hook.Hook[*ModelEvent]
func (*BaseApp) OnModelBeforeDelete ¶
func (app *BaseApp) OnModelBeforeDelete() *hook.Hook[*ModelEvent]
func (*BaseApp) OnModelBeforeUpdate ¶
func (app *BaseApp) OnModelBeforeUpdate() *hook.Hook[*ModelEvent]
func (*BaseApp) OnRealtimeAfterMessageSend ¶
func (app *BaseApp) OnRealtimeAfterMessageSend() *hook.Hook[*RealtimeMessageEvent]
func (*BaseApp) OnRealtimeAfterSubscribeRequest ¶
func (app *BaseApp) OnRealtimeAfterSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]
func (*BaseApp) OnRealtimeBeforeMessageSend ¶
func (app *BaseApp) OnRealtimeBeforeMessageSend() *hook.Hook[*RealtimeMessageEvent]
func (*BaseApp) OnRealtimeBeforeSubscribeRequest ¶
func (app *BaseApp) OnRealtimeBeforeSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]
func (*BaseApp) OnRealtimeConnectRequest ¶
func (app *BaseApp) OnRealtimeConnectRequest() *hook.Hook[*RealtimeConnectEvent]
func (*BaseApp) OnRealtimeDisconnectRequest ¶
func (app *BaseApp) OnRealtimeDisconnectRequest() *hook.Hook[*RealtimeDisconnectEvent]
func (*BaseApp) OnRecordAfterConfirmEmailChangeRequest ¶
func (app *BaseApp) OnRecordAfterConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent]
func (*BaseApp) OnRecordAfterConfirmPasswordResetRequest ¶
func (app *BaseApp) OnRecordAfterConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent]
func (*BaseApp) OnRecordAfterConfirmVerificationRequest ¶
func (app *BaseApp) OnRecordAfterConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent]
func (*BaseApp) OnRecordAfterCreateRequest ¶
func (app *BaseApp) OnRecordAfterCreateRequest() *hook.Hook[*RecordCreateEvent]
func (*BaseApp) OnRecordAfterDeleteRequest ¶
func (app *BaseApp) OnRecordAfterDeleteRequest() *hook.Hook[*RecordDeleteEvent]
func (*BaseApp) OnRecordAfterRequestEmailChangeRequest ¶
func (app *BaseApp) OnRecordAfterRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent]
func (*BaseApp) OnRecordAfterRequestPasswordResetRequest ¶
func (app *BaseApp) OnRecordAfterRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent]
func (*BaseApp) OnRecordAfterRequestVerificationRequest ¶
func (app *BaseApp) OnRecordAfterRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent]
func (*BaseApp) OnRecordAfterUnlinkExternalAuthRequest ¶
func (app *BaseApp) OnRecordAfterUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent]
func (*BaseApp) OnRecordAfterUpdateRequest ¶
func (app *BaseApp) OnRecordAfterUpdateRequest() *hook.Hook[*RecordUpdateEvent]
func (*BaseApp) OnRecordAuthRequest ¶
func (app *BaseApp) OnRecordAuthRequest() *hook.Hook[*RecordAuthEvent]
func (*BaseApp) OnRecordBeforeConfirmEmailChangeRequest ¶
func (app *BaseApp) OnRecordBeforeConfirmEmailChangeRequest() *hook.Hook[*RecordConfirmEmailChangeEvent]
func (*BaseApp) OnRecordBeforeConfirmPasswordResetRequest ¶
func (app *BaseApp) OnRecordBeforeConfirmPasswordResetRequest() *hook.Hook[*RecordConfirmPasswordResetEvent]
func (*BaseApp) OnRecordBeforeConfirmVerificationRequest ¶
func (app *BaseApp) OnRecordBeforeConfirmVerificationRequest() *hook.Hook[*RecordConfirmVerificationEvent]
func (*BaseApp) OnRecordBeforeCreateRequest ¶
func (app *BaseApp) OnRecordBeforeCreateRequest() *hook.Hook[*RecordCreateEvent]
func (*BaseApp) OnRecordBeforeDeleteRequest ¶
func (app *BaseApp) OnRecordBeforeDeleteRequest() *hook.Hook[*RecordDeleteEvent]
func (*BaseApp) OnRecordBeforeRequestEmailChangeRequest ¶
func (app *BaseApp) OnRecordBeforeRequestEmailChangeRequest() *hook.Hook[*RecordRequestEmailChangeEvent]
func (*BaseApp) OnRecordBeforeRequestPasswordResetRequest ¶
func (app *BaseApp) OnRecordBeforeRequestPasswordResetRequest() *hook.Hook[*RecordRequestPasswordResetEvent]
func (*BaseApp) OnRecordBeforeRequestVerificationRequest ¶
func (app *BaseApp) OnRecordBeforeRequestVerificationRequest() *hook.Hook[*RecordRequestVerificationEvent]
func (*BaseApp) OnRecordBeforeUnlinkExternalAuthRequest ¶
func (app *BaseApp) OnRecordBeforeUnlinkExternalAuthRequest() *hook.Hook[*RecordUnlinkExternalAuthEvent]
func (*BaseApp) OnRecordBeforeUpdateRequest ¶
func (app *BaseApp) OnRecordBeforeUpdateRequest() *hook.Hook[*RecordUpdateEvent]
func (*BaseApp) OnRecordListExternalAuthsRequest ¶
func (app *BaseApp) OnRecordListExternalAuthsRequest() *hook.Hook[*RecordListExternalAuthsEvent]
func (*BaseApp) OnRecordViewRequest ¶
func (app *BaseApp) OnRecordViewRequest() *hook.Hook[*RecordViewEvent]
func (*BaseApp) OnRecordsListRequest ¶
func (app *BaseApp) OnRecordsListRequest() *hook.Hook[*RecordsListEvent]
func (*BaseApp) OnSettingsAfterUpdateRequest ¶
func (app *BaseApp) OnSettingsAfterUpdateRequest() *hook.Hook[*SettingsUpdateEvent]
func (*BaseApp) OnSettingsBeforeUpdateRequest ¶
func (app *BaseApp) OnSettingsBeforeUpdateRequest() *hook.Hook[*SettingsUpdateEvent]
func (*BaseApp) OnSettingsListRequest ¶
func (app *BaseApp) OnSettingsListRequest() *hook.Hook[*SettingsListEvent]
func (*BaseApp) RefreshSettings ¶
RefreshSettings reinitializes and reloads the stored application settings.
func (*BaseApp) ResetBootstrapState ¶
ResetBootstrapState takes care for releasing initialized app resources (eg. closing db connections).
func (*BaseApp) SubscriptionsBroker ¶
func (app *BaseApp) SubscriptionsBroker() *subscriptions.Broker
SubscriptionsBroker returns the app realtime subscriptions broker instance.
type BaseAppConfig ¶
type BaseAppConfig struct { DataDir string EncryptionEnv string IsDebug bool DataMaxOpenConns int // default to 500 DataMaxIdleConns int // default 20 LogsMaxOpenConns int // default to 100 LogsMaxIdleConns int // default to 5 }
BaseAppConfig defines a BaseApp configuration option
type BootstrapEvent ¶
type BootstrapEvent struct {
App App
}
type CollectionCreateEvent ¶
type CollectionCreateEvent struct { HttpContext echo.Context Collection *models.Collection }
type CollectionDeleteEvent ¶
type CollectionDeleteEvent struct { HttpContext echo.Context Collection *models.Collection }
type CollectionUpdateEvent ¶
type CollectionUpdateEvent struct { HttpContext echo.Context Collection *models.Collection }
type CollectionViewEvent ¶
type CollectionViewEvent struct { HttpContext echo.Context Collection *models.Collection }
type CollectionsImportEvent ¶
type CollectionsImportEvent struct { HttpContext echo.Context Collections []*models.Collection }
type CollectionsListEvent ¶
type CollectionsListEvent struct { HttpContext echo.Context Collections []*models.Collection Result *search.Result }
type FileDownloadEvent ¶
type FileDownloadEvent struct { HttpContext echo.Context Collection *models.Collection Record *models.Record FileField *schema.SchemaField ServedPath string ServedName string }
type MailerAdminEvent ¶
type MailerRecordEvent ¶
type RealtimeConnectEvent ¶
type RealtimeConnectEvent struct { HttpContext echo.Context Client subscriptions.Client }
type RealtimeDisconnectEvent ¶
type RealtimeDisconnectEvent struct { HttpContext echo.Context Client subscriptions.Client }
type RealtimeMessageEvent ¶
type RealtimeMessageEvent struct { HttpContext echo.Context Client subscriptions.Client Message *subscriptions.Message }
type RealtimeSubscribeEvent ¶
type RealtimeSubscribeEvent struct { HttpContext echo.Context Client subscriptions.Client Subscriptions []string }
type RecordAuthEvent ¶
type RecordCreateEvent ¶
type RecordDeleteEvent ¶
type RecordListExternalAuthsEvent ¶
type RecordListExternalAuthsEvent struct { HttpContext echo.Context Record *models.Record ExternalAuths []*models.ExternalAuth }
type RecordUnlinkExternalAuthEvent ¶
type RecordUnlinkExternalAuthEvent struct { HttpContext echo.Context Record *models.Record ExternalAuth *models.ExternalAuth }
type RecordUpdateEvent ¶
type RecordViewEvent ¶
type RecordsListEvent ¶
type ServeEvent ¶
type ServeEvent struct { App App Router *echo.Echo }