Documentation ¶
Overview ¶
Package models implements various services used for request data validation and applying changes to existing DB models through the app Dao.
Index ¶
- type AdminLogin
- type AdminPasswordResetConfirm
- type AdminPasswordResetRequest
- type AdminUpsert
- type AppleClientSecretCreate
- type BackupCreate
- type BackupUpload
- type BeforeOAuth2RecordCreateFunc
- type CollectionUpsert
- type CollectionsImport
- type InterceptorFunc
- type InterceptorNextFunc
- type RealtimeSubscribe
- type RecordEmailChangeConfirm
- type RecordEmailChangeRequest
- type RecordOAuth2Login
- func (form *RecordOAuth2Login) SetBeforeNewRecordCreateFunc(f BeforeOAuth2RecordCreateFunc)
- func (form *RecordOAuth2Login) SetDao(dao *daos.Dao)
- func (form *RecordOAuth2Login) Submit(interceptors ...InterceptorFunc[*RecordOAuth2LoginData]) (*models.Record, *auth.AuthUser, error)
- func (form *RecordOAuth2Login) Validate() error
- type RecordOAuth2LoginData
- type RecordPasswordLogin
- type RecordPasswordResetConfirm
- type RecordPasswordResetRequest
- type RecordUpsert
- func (form *RecordUpsert) AddFiles(key string, files ...*filesystem.File) error
- func (form *RecordUpsert) Data() map[string]any
- func (form *RecordUpsert) DrySubmit(callback func(txDao *daos.Dao) error) error
- func (form *RecordUpsert) FilesToDelete() []string
- func (form *RecordUpsert) FilesToUpload() map[string][]*filesystem.File
- func (form *RecordUpsert) LoadData(requestData map[string]any) error
- func (form *RecordUpsert) LoadRequest(r *http.Request, keyPrefix string) error
- func (form *RecordUpsert) RemoveFiles(key string, toDelete ...string) error
- func (form *RecordUpsert) SetDao(dao *daos.Dao)
- func (form *RecordUpsert) SetFullManageAccess(fullManageAccess bool)
- func (form *RecordUpsert) Submit(interceptors ...InterceptorFunc[*models.Record]) error
- func (form *RecordUpsert) Validate() error
- func (form *RecordUpsert) ValidateAndFill() error
- type RecordVerificationConfirm
- type RecordVerificationRequest
- type SettingsUpsert
- type TestEmailSend
- type TestS3Filesystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminLogin ¶
type AdminLogin struct { Identity string `form:"identity" json:"identity"` Password string `form:"password" json:"password"` // contains filtered or unexported fields }
AdminLogin is an admin email/pass login form.
func NewAdminLogin ¶
func NewAdminLogin(app core.App) *AdminLogin
NewAdminLogin creates a new AdminLogin form initialized with the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*AdminLogin) SetDao ¶
func (form *AdminLogin) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*AdminLogin) Submit ¶
func (form *AdminLogin) Submit(interceptors ...InterceptorFunc[*models.Admin]) (*models.Admin, error)
Submit validates and submits the admin form. On success returns the authorized admin model.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*AdminLogin) Validate ¶
func (form *AdminLogin) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type AdminPasswordResetConfirm ¶
type AdminPasswordResetConfirm struct { Token string `form:"token" json:"token"` Password string `form:"password" json:"password"` PasswordConfirm string `form:"passwordConfirm" json:"passwordConfirm"` // contains filtered or unexported fields }
AdminPasswordResetConfirm is an admin password reset confirmation form.
func NewAdminPasswordResetConfirm ¶
func NewAdminPasswordResetConfirm(app core.App) *AdminPasswordResetConfirm
NewAdminPasswordResetConfirm creates a new AdminPasswordResetConfirm form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*AdminPasswordResetConfirm) SetDao ¶
func (form *AdminPasswordResetConfirm) SetDao(dao *daos.Dao)
SetDao replaces the form Dao instance with the provided one.
This is useful if you want to use a specific transaction Dao instance instead of the default app.Dao().
func (*AdminPasswordResetConfirm) Submit ¶
func (form *AdminPasswordResetConfirm) Submit(interceptors ...InterceptorFunc[*models.Admin]) (*models.Admin, error)
Submit validates and submits the admin password reset confirmation form. On success returns the updated admin model associated to `form.Token`.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*AdminPasswordResetConfirm) Validate ¶
func (form *AdminPasswordResetConfirm) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type AdminPasswordResetRequest ¶
type AdminPasswordResetRequest struct { Email string `form:"email" json:"email"` // contains filtered or unexported fields }
AdminPasswordResetRequest is an admin password reset request form.
func NewAdminPasswordResetRequest ¶
func NewAdminPasswordResetRequest(app core.App) *AdminPasswordResetRequest
NewAdminPasswordResetRequest creates a new AdminPasswordResetRequest form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*AdminPasswordResetRequest) SetDao ¶
func (form *AdminPasswordResetRequest) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*AdminPasswordResetRequest) Submit ¶
func (form *AdminPasswordResetRequest) Submit(interceptors ...InterceptorFunc[*models.Admin]) error
Submit validates and submits the form. On success sends a password reset email to the `form.Email` admin.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*AdminPasswordResetRequest) Validate ¶
func (form *AdminPasswordResetRequest) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
This method doesn't verify that admin with `form.Email` exists (this is done on Submit).
type AdminUpsert ¶
type AdminUpsert struct { Id string `form:"id" json:"id"` Avatar int `form:"avatar" json:"avatar"` Email string `form:"email" json:"email"` Password string `form:"password" json:"password"` PasswordConfirm string `form:"passwordConfirm" json:"passwordConfirm"` // contains filtered or unexported fields }
AdminUpsert is a models.Admin upsert (create/update) form.
func NewAdminUpsert ¶
func NewAdminUpsert(app core.App, admin *models.Admin) *AdminUpsert
NewAdminUpsert creates a new AdminUpsert form with initializer config created from the provided core.App and models.Admin instances (for create you could pass a pointer to an empty Admin - `&models.Admin{}`).
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*AdminUpsert) SetDao ¶
func (form *AdminUpsert) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*AdminUpsert) Submit ¶
func (form *AdminUpsert) Submit(interceptors ...InterceptorFunc[*models.Admin]) error
Submit validates the form and upserts the form admin model.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*AdminUpsert) Validate ¶
func (form *AdminUpsert) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type AppleClientSecretCreate ¶
type AppleClientSecretCreate struct { // ClientId is the identifier of your app (aka. Service ID). ClientId string `form:"clientId" json:"clientId"` // TeamId is a 10-character string associated with your developer account // (usually could be found next to your name in the Apple Developer site). TeamId string `form:"teamId" json:"teamId"` // KeyId is a 10-character key identifier generated for the "Sign in with Apple" // private key associated with your developer account. KeyId string `form:"keyId" json:"keyId"` // PrivateKey is the private key associated to your app. // Usually wrapped within -----BEGIN PRIVATE KEY----- X -----END PRIVATE KEY-----. PrivateKey string `form:"privateKey" json:"privateKey"` // Duration specifies how long the generated JWT should be considered valid. // The specified value must be in seconds and max 15777000 (~6months). Duration int `form:"duration" json:"duration"` // contains filtered or unexported fields }
AppleClientSecretCreate is a form struct to generate a new Apple Client Secret.
Reference: https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens
func NewAppleClientSecretCreate ¶
func NewAppleClientSecretCreate(app core.App) *AppleClientSecretCreate
NewAppleClientSecretCreate creates a new AppleClientSecretCreate form with initializer config created from the provided core.App instances.
func (*AppleClientSecretCreate) Submit ¶
func (form *AppleClientSecretCreate) Submit() (string, error)
Submit validates the form and returns a new Apple Client Secret JWT.
func (*AppleClientSecretCreate) Validate ¶
func (form *AppleClientSecretCreate) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type BackupCreate ¶
type BackupCreate struct { Name string `form:"name" json:"name"` // contains filtered or unexported fields }
BackupCreate is a request form for creating a new app backup.
func NewBackupCreate ¶
func NewBackupCreate(app core.App) *BackupCreate
NewBackupCreate creates new BackupCreate request form.
func (*BackupCreate) SetContext ¶
func (form *BackupCreate) SetContext(ctx context.Context)
SetContext replaces the default form context with the provided one.
func (*BackupCreate) Submit ¶
func (form *BackupCreate) Submit(interceptors ...InterceptorFunc[string]) error
Submit validates the form and creates the app backup.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before creating the backup.
func (*BackupCreate) Validate ¶
func (form *BackupCreate) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type BackupUpload ¶
type BackupUpload struct { File *filesystem.File `json:"file"` // contains filtered or unexported fields }
BackupUpload is a request form for uploading a new app backup.
func NewBackupUpload ¶
func NewBackupUpload(app core.App) *BackupUpload
NewBackupUpload creates new BackupUpload request form.
func (*BackupUpload) SetContext ¶
func (form *BackupUpload) SetContext(ctx context.Context)
SetContext replaces the default form upload context with the provided one.
func (*BackupUpload) Submit ¶
func (form *BackupUpload) Submit(interceptors ...InterceptorFunc[*filesystem.File]) error
Submit validates the form and upload the backup file.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before uploading the backup.
func (*BackupUpload) Validate ¶
func (form *BackupUpload) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type BeforeOAuth2RecordCreateFunc ¶
type BeforeOAuth2RecordCreateFunc func(createForm *RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error
BeforeOAuth2RecordCreateFunc defines a callback function that will be called before OAuth2 new Record creation.
type CollectionUpsert ¶
type CollectionUpsert struct { Id string `form:"id" json:"id"` Type string `form:"type" json:"type"` Name string `form:"name" json:"name"` System bool `form:"system" json:"system"` Schema schema.Schema `form:"schema" json:"schema"` Indexes types.JsonArray[string] `form:"indexes" json:"indexes"` ListRule *string `form:"listRule" json:"listRule"` ViewRule *string `form:"viewRule" json:"viewRule"` CreateRule *string `form:"createRule" json:"createRule"` UpdateRule *string `form:"updateRule" json:"updateRule"` DeleteRule *string `form:"deleteRule" json:"deleteRule"` Options types.JsonMap `form:"options" json:"options"` // contains filtered or unexported fields }
CollectionUpsert is a models.Collection upsert (create/update) form.
func NewCollectionUpsert ¶
func NewCollectionUpsert(app core.App, collection *models.Collection) *CollectionUpsert
NewCollectionUpsert creates a new CollectionUpsert form with initializer config created from the provided core.App and models.Collection instances (for create you could pass a pointer to an empty Collection - `&models.Collection{}`).
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*CollectionUpsert) SetDao ¶
func (form *CollectionUpsert) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*CollectionUpsert) Submit ¶
func (form *CollectionUpsert) Submit(interceptors ...InterceptorFunc[*models.Collection]) error
Submit validates the form and upserts the form's Collection model.
On success the related record table schema will be auto updated.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*CollectionUpsert) Validate ¶
func (form *CollectionUpsert) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type CollectionsImport ¶
type CollectionsImport struct { Collections []*models.Collection `form:"collections" json:"collections"` DeleteMissing bool `form:"deleteMissing" json:"deleteMissing"` // contains filtered or unexported fields }
CollectionsImport is a form model to bulk import (create, replace and delete) collections from a user provided list.
func NewCollectionsImport ¶
func NewCollectionsImport(app core.App) *CollectionsImport
NewCollectionsImport creates a new CollectionsImport form with initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*CollectionsImport) SetDao ¶
func (form *CollectionsImport) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*CollectionsImport) Submit ¶
func (form *CollectionsImport) Submit(interceptors ...InterceptorFunc[[]*models.Collection]) error
Submit applies the import, aka.: - imports the form collections (create or replace) - sync the collection changes with their related records table - ensures the integrity of the imported structure (aka. run validations for each collection) - if [form.DeleteMissing] is set, deletes all local collections that are not found in the imports list
All operations are wrapped in a single transaction that are rollbacked on the first encountered error.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*CollectionsImport) Validate ¶
func (form *CollectionsImport) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type InterceptorFunc ¶
type InterceptorFunc[T any] func(next InterceptorNextFunc[T]) InterceptorNextFunc[T]
InterceptorFunc defines a single interceptor function that will execute the provided next func handler.
type InterceptorNextFunc ¶
InterceptorNextFunc is a interceptor handler function. Usually used in combination with InterceptorFunc.
type RealtimeSubscribe ¶
type RealtimeSubscribe struct { ClientId string `form:"clientId" json:"clientId"` Subscriptions []string `form:"subscriptions" json:"subscriptions"` }
RealtimeSubscribe is a realtime subscriptions request form.
func NewRealtimeSubscribe ¶
func NewRealtimeSubscribe() *RealtimeSubscribe
NewRealtimeSubscribe creates new RealtimeSubscribe request form.
func (*RealtimeSubscribe) Validate ¶
func (form *RealtimeSubscribe) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordEmailChangeConfirm ¶
type RecordEmailChangeConfirm struct { Token string `form:"token" json:"token"` Password string `form:"password" json:"password"` // contains filtered or unexported fields }
RecordEmailChangeConfirm is an auth record email change confirmation form.
func NewRecordEmailChangeConfirm ¶
func NewRecordEmailChangeConfirm(app core.App, collection *models.Collection) *RecordEmailChangeConfirm
NewRecordEmailChangeConfirm creates a new RecordEmailChangeConfirm form initialized with from the provided core.App and models.Collection instances.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordEmailChangeConfirm) SetDao ¶
func (form *RecordEmailChangeConfirm) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordEmailChangeConfirm) Submit ¶
func (form *RecordEmailChangeConfirm) Submit(interceptors ...InterceptorFunc[*models.Record]) (*models.Record, error)
Submit validates and submits the auth record email change confirmation form. On success returns the updated auth record associated to `form.Token`.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordEmailChangeConfirm) Validate ¶
func (form *RecordEmailChangeConfirm) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordEmailChangeRequest ¶
type RecordEmailChangeRequest struct { NewEmail string `form:"newEmail" json:"newEmail"` // contains filtered or unexported fields }
RecordEmailChangeRequest is an auth record email change request form.
func NewRecordEmailChangeRequest ¶
func NewRecordEmailChangeRequest(app core.App, record *models.Record) *RecordEmailChangeRequest
NewRecordEmailChangeRequest creates a new RecordEmailChangeRequest form initialized with from the provided core.App and models.Record instances.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordEmailChangeRequest) SetDao ¶
func (form *RecordEmailChangeRequest) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordEmailChangeRequest) Submit ¶
func (form *RecordEmailChangeRequest) Submit(interceptors ...InterceptorFunc[*models.Record]) error
Submit validates and sends the change email request.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordEmailChangeRequest) Validate ¶
func (form *RecordEmailChangeRequest) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordOAuth2Login ¶
type RecordOAuth2Login struct { // The name of the OAuth2 client provider (eg. "google") Provider string `form:"provider" json:"provider"` // The authorization code returned from the initial request. Code string `form:"code" json:"code"` // The optional PKCE code verifier as part of the code_challenge sent with the initial request. CodeVerifier string `form:"codeVerifier" json:"codeVerifier"` // The redirect url sent with the initial request. RedirectUrl string `form:"redirectUrl" json:"redirectUrl"` // Additional data that will be used for creating a new auth record // if an existing OAuth2 account doesn't exist. CreateData map[string]any `form:"createData" json:"createData"` // contains filtered or unexported fields }
RecordOAuth2Login is an auth record OAuth2 login form.
func NewRecordOAuth2Login ¶
func NewRecordOAuth2Login(app core.App, collection *models.Collection, optAuthRecord *models.Record) *RecordOAuth2Login
NewRecordOAuth2Login creates a new RecordOAuth2Login form with initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordOAuth2Login) SetBeforeNewRecordCreateFunc ¶
func (form *RecordOAuth2Login) SetBeforeNewRecordCreateFunc(f BeforeOAuth2RecordCreateFunc)
SetBeforeNewRecordCreateFunc sets a before OAuth2 record create callback handler.
func (*RecordOAuth2Login) SetDao ¶
func (form *RecordOAuth2Login) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordOAuth2Login) Submit ¶
func (form *RecordOAuth2Login) Submit( interceptors ...InterceptorFunc[*RecordOAuth2LoginData], ) (*models.Record, *auth.AuthUser, error)
Submit validates and submits the form.
If an auth record doesn't exist, it will make an attempt to create it based on the fetched OAuth2 profile data via a local RecordUpsert form. You can intercept/modify the Record create form with [form.SetBeforeNewRecordCreateFunc()].
You can also optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
On success returns the authorized record model and the fetched provider's data.
func (*RecordOAuth2Login) Validate ¶
func (form *RecordOAuth2Login) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordOAuth2LoginData ¶
type RecordOAuth2LoginData struct { ExternalAuth *models.ExternalAuth Record *models.Record OAuth2User *auth.AuthUser ProviderClient auth.Provider }
RecordOAuth2LoginData defines the OA
type RecordPasswordLogin ¶
type RecordPasswordLogin struct { Identity string `form:"identity" json:"identity"` Password string `form:"password" json:"password"` // contains filtered or unexported fields }
RecordPasswordLogin is record username/email + password login form.
func NewRecordPasswordLogin ¶
func NewRecordPasswordLogin(app core.App, collection *models.Collection) *RecordPasswordLogin
NewRecordPasswordLogin creates a new RecordPasswordLogin form initialized with from the provided core.App and models.Collection instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordPasswordLogin) SetDao ¶
func (form *RecordPasswordLogin) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordPasswordLogin) Submit ¶
func (form *RecordPasswordLogin) Submit(interceptors ...InterceptorFunc[*models.Record]) (*models.Record, error)
Submit validates and submits the form. On success returns the authorized record model.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordPasswordLogin) Validate ¶
func (form *RecordPasswordLogin) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordPasswordResetConfirm ¶
type RecordPasswordResetConfirm struct { Token string `form:"token" json:"token"` Password string `form:"password" json:"password"` PasswordConfirm string `form:"passwordConfirm" json:"passwordConfirm"` // contains filtered or unexported fields }
RecordPasswordResetConfirm is an auth record password reset confirmation form.
func NewRecordPasswordResetConfirm ¶
func NewRecordPasswordResetConfirm(app core.App, collection *models.Collection) *RecordPasswordResetConfirm
NewRecordPasswordResetConfirm creates a new RecordPasswordResetConfirm form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordPasswordResetConfirm) SetDao ¶
func (form *RecordPasswordResetConfirm) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordPasswordResetConfirm) Submit ¶
func (form *RecordPasswordResetConfirm) Submit(interceptors ...InterceptorFunc[*models.Record]) (*models.Record, error)
Submit validates and submits the form. On success returns the updated auth record associated to `form.Token`.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordPasswordResetConfirm) Validate ¶
func (form *RecordPasswordResetConfirm) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordPasswordResetRequest ¶
type RecordPasswordResetRequest struct { Email string `form:"email" json:"email"` // contains filtered or unexported fields }
RecordPasswordResetRequest is an auth record reset password request form.
func NewRecordPasswordResetRequest ¶
func NewRecordPasswordResetRequest(app core.App, collection *models.Collection) *RecordPasswordResetRequest
NewRecordPasswordResetRequest creates a new RecordPasswordResetRequest form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordPasswordResetRequest) SetDao ¶
func (form *RecordPasswordResetRequest) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordPasswordResetRequest) Submit ¶
func (form *RecordPasswordResetRequest) Submit(interceptors ...InterceptorFunc[*models.Record]) error
Submit validates and submits the form. On success, sends a password reset email to the `form.Email` auth record.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordPasswordResetRequest) Validate ¶
func (form *RecordPasswordResetRequest) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
This method doesn't check whether auth record with `form.Email` exists (this is done on Submit).
type RecordUpsert ¶
type RecordUpsert struct { // base model fields Id string `json:"id"` // auth collection fields // --- Username string `json:"username"` Email string `json:"email"` EmailVisibility bool `json:"emailVisibility"` Verified bool `json:"verified"` Password string `json:"password"` PasswordConfirm string `json:"passwordConfirm"` OldPassword string `json:"oldPassword"` // contains filtered or unexported fields }
RecordUpsert is a models.Record upsert (create/update) form.
func NewRecordUpsert ¶
func NewRecordUpsert(app core.App, record *models.Record) *RecordUpsert
NewRecordUpsert creates a new RecordUpsert form with initializer config created from the provided core.App and models.Record instances (for create you could pass a pointer to an empty Record - models.NewRecord(collection)).
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordUpsert) AddFiles ¶
func (form *RecordUpsert) AddFiles(key string, files ...*filesystem.File) error
AddFiles adds the provided file(s) to the specified file field.
If the file field is a SINGLE-value file field (aka. "Max Select = 1"), then the newly added file will REPLACE the existing one. In this case if you pass more than 1 files only the first one will be assigned.
If the file field is a MULTI-value file field (aka. "Max Select > 1"), then the newly added file(s) will be APPENDED to the existing one(s).
Example
f1, _ := filesystem.NewFileFromPath("/path/to/file1.txt") f2, _ := filesystem.NewFileFromPath("/path/to/file2.txt") form.AddFiles("documents", f1, f2)
func (*RecordUpsert) Data ¶
func (form *RecordUpsert) Data() map[string]any
Data returns the loaded form's data.
func (*RecordUpsert) DrySubmit ¶
func (form *RecordUpsert) DrySubmit(callback func(txDao *daos.Dao) error) error
DrySubmit performs a form submit within a transaction and reverts it. For actual record persistence, check the `form.Submit()` method.
This method doesn't handle file uploads/deletes or trigger any app events!
func (*RecordUpsert) FilesToDelete ¶
func (form *RecordUpsert) FilesToDelete() []string
FilesToUpload returns the parsed request filenames ready to be deleted.
func (*RecordUpsert) FilesToUpload ¶
func (form *RecordUpsert) FilesToUpload() map[string][]*filesystem.File
FilesToUpload returns the parsed request files ready for upload.
func (*RecordUpsert) LoadData ¶
func (form *RecordUpsert) LoadData(requestData map[string]any) error
LoadData loads and normalizes the provided regular record data fields into the form.
func (*RecordUpsert) LoadRequest ¶
func (form *RecordUpsert) LoadRequest(r *http.Request, keyPrefix string) error
LoadRequest extracts the json or multipart/form-data request data and lods it into the form.
File upload is supported only via multipart/form-data.
func (*RecordUpsert) RemoveFiles ¶
func (form *RecordUpsert) RemoveFiles(key string, toDelete ...string) error
RemoveFiles removes a single or multiple file from the specified file field.
NB! If filesToDelete is not set it will remove all existing files assigned to the file field (including those assigned with AddFiles)!
Example
// mark only only 2 files for removal form.RemoveFiles("documents", "file1_aw4bdrvws6.txt", "file2_xwbs36bafv.txt") // mark all "documents" files for removal form.RemoveFiles("documents")
func (*RecordUpsert) SetDao ¶
func (form *RecordUpsert) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordUpsert) SetFullManageAccess ¶
func (form *RecordUpsert) SetFullManageAccess(fullManageAccess bool)
SetFullManageAccess sets the manageAccess bool flag of the current form to enable/disable directly changing some system record fields (often used with auth collection records).
func (*RecordUpsert) Submit ¶
func (form *RecordUpsert) Submit(interceptors ...InterceptorFunc[*models.Record]) error
Submit validates the form and upserts the form Record model.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordUpsert) Validate ¶
func (form *RecordUpsert) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
func (*RecordUpsert) ValidateAndFill ¶
func (form *RecordUpsert) ValidateAndFill() error
type RecordVerificationConfirm ¶
type RecordVerificationConfirm struct { Token string `form:"token" json:"token"` // contains filtered or unexported fields }
RecordVerificationConfirm is an auth record email verification confirmation form.
func NewRecordVerificationConfirm ¶
func NewRecordVerificationConfirm(app core.App, collection *models.Collection) *RecordVerificationConfirm
NewRecordVerificationConfirm creates a new RecordVerificationConfirm form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordVerificationConfirm) SetDao ¶
func (form *RecordVerificationConfirm) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordVerificationConfirm) Submit ¶
func (form *RecordVerificationConfirm) Submit(interceptors ...InterceptorFunc[*models.Record]) (*models.Record, error)
Submit validates and submits the form. On success returns the verified auth record associated to `form.Token`.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordVerificationConfirm) Validate ¶
func (form *RecordVerificationConfirm) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type RecordVerificationRequest ¶
type RecordVerificationRequest struct { Email string `form:"email" json:"email"` // contains filtered or unexported fields }
RecordVerificationRequest is an auth record email verification request form.
func NewRecordVerificationRequest ¶
func NewRecordVerificationRequest(app core.App, collection *models.Collection) *RecordVerificationRequest
NewRecordVerificationRequest creates a new RecordVerificationRequest form initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordVerificationRequest) SetDao ¶
func (form *RecordVerificationRequest) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordVerificationRequest) Submit ¶
func (form *RecordVerificationRequest) Submit(interceptors ...InterceptorFunc[*models.Record]) error
Submit validates and sends a verification request email to the `form.Email` auth record.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*RecordVerificationRequest) Validate ¶
func (form *RecordVerificationRequest) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
// This method doesn't verify that auth record with `form.Email` exists (this is done on Submit).
type SettingsUpsert ¶
SettingsUpsert is a settings.Settings upsert (create/update) form.
func NewSettingsUpsert ¶
func NewSettingsUpsert(app core.App) *SettingsUpsert
NewSettingsUpsert creates a new SettingsUpsert form with initializer config created from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*SettingsUpsert) SetDao ¶
func (form *SettingsUpsert) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*SettingsUpsert) Submit ¶
func (form *SettingsUpsert) Submit(interceptors ...InterceptorFunc[*settings.Settings]) error
Submit validates the form and upserts the loaded settings.
On success the app settings will be refreshed with the form ones.
You can optionally provide a list of InterceptorFunc to further modify the form behavior before persisting it.
func (*SettingsUpsert) Validate ¶
func (form *SettingsUpsert) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type TestEmailSend ¶
type TestEmailSend struct { Template string `form:"template" json:"template"` Email string `form:"email" json:"email"` // contains filtered or unexported fields }
TestEmailSend is a email template test request form.
func NewTestEmailSend ¶
func NewTestEmailSend(app core.App) *TestEmailSend
NewTestEmailSend creates and initializes new TestEmailSend form.
func (*TestEmailSend) Submit ¶
func (form *TestEmailSend) Submit() error
Submit validates and sends a test email to the form.Email address.
func (*TestEmailSend) Validate ¶
func (form *TestEmailSend) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
type TestS3Filesystem ¶
type TestS3Filesystem struct { // The name of the filesystem - storage or backups Filesystem string `form:"filesystem" json:"filesystem"` // contains filtered or unexported fields }
TestS3Filesystem defines a S3 filesystem connection test.
func NewTestS3Filesystem ¶
func NewTestS3Filesystem(app core.App) *TestS3Filesystem
NewTestS3Filesystem creates and initializes new TestS3Filesystem form.
func (*TestS3Filesystem) Submit ¶
func (form *TestS3Filesystem) Submit() error
Submit validates and performs a S3 filesystem connection test.
func (*TestS3Filesystem) Validate ¶
func (form *TestS3Filesystem) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.
Source Files ¶
- admin_login.go
- admin_password_reset_confirm.go
- admin_password_reset_request.go
- admin_upsert.go
- apple_client_secret_create.go
- backup_create.go
- backup_upload.go
- base.go
- collection_upsert.go
- collections_import.go
- realtime_subscribe.go
- record_email_change_confirm.go
- record_email_change_request.go
- record_oauth2_login.go
- record_password_login.go
- record_password_reset_confirm.go
- record_password_reset_request.go
- record_upsert.go
- record_verification_confirm.go
- record_verification_request.go
- settings_upsert.go
- test_email_send.go
- test_s3_filesystem.go
Directories ¶
Path | Synopsis |
---|---|
Package validators implements custom shared PocketBase validators.
|
Package validators implements custom shared PocketBase validators. |