models

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SelectWhere     = Where[*dialect.SelectQuery]()
	UpdateWhere     = Where[*dialect.UpdateQuery]()
	DeleteWhere     = Where[*dialect.DeleteQuery]()
	OnConflictWhere = Where[*clause.ConflictClause]() // Used in ON CONFLICT DO UPDATE
)
View Source
var (
	SelectThenLoad = getThenLoaders[*dialect.SelectQuery]()
	InsertThenLoad = getThenLoaders[*dialect.InsertQuery]()
	UpdateThenLoad = getThenLoaders[*dialect.UpdateQuery]()
)
View Source
var (
	SelectJoins = getJoins[*dialect.SelectQuery]
	UpdateJoins = getJoins[*dialect.UpdateQuery]
)
View Source
var ColumnNames = struct {
	Credentials      credentialColumnNames
	Files            fileColumnNames
	Items            itemColumnNames
	SchemaMigrations schemaMigrationColumnNames
	Users            userColumnNames
}{
	Credentials: credentialColumnNames{
		CredID:                "cred_id",
		CredPublicKey:         "cred_public_key",
		SignCount:             "sign_count",
		Transports:            "transports",
		UserVerified:          "user_verified",
		BackupEligible:        "backup_eligible",
		BackupState:           "backup_state",
		AttestationObject:     "attestation_object",
		AttestationClientData: "attestation_client_data",
		CreatedAt:             "created_at",
		LastUsed:              "last_used",
		UserID:                "user_id",
	},
	Files: fileColumnNames{
		ID:     "id",
		Name:   "name",
		Data:   "data",
		UserID: "user_id",
	},
	Items: itemColumnNames{
		ID:          "id",
		Name:        "name",
		Added:       "added",
		Description: "description",
		Price:       "price",
		Quantity:    "quantity",
		UserID:      "user_id",
	},
	SchemaMigrations: schemaMigrationColumnNames{
		Version: "version",
	},
	Users: userColumnNames{
		ID:               "id",
		Username:         "username",
		Password:         "password",
		ProfilePictureID: "profile_picture_id",
		WebauthnID:       "webauthn_id",
	},
}
View Source
var CredentialColumns = buildCredentialColumns("credential")
View Source
var CredentialErrors = &credentialErrors{
	ErrUniquePkMainCredential: &UniqueConstraintError{
		schema:  "",
		table:   "credential",
		columns: []string{"cred_id"},
		s:       "pk_main_credential",
	},
}
View Source
var Credentials = sqlite.NewTablex[*Credential, CredentialSlice, *CredentialSetter]("", "credential")

Credentials contains methods to work with the credential table

View Source
var ErrUniqueConstraint = &UniqueConstraintError{s: ""}

ErrUniqueConstraint captures all unique constraint errors by explicitly leaving `s` empty.

View Source
var FileColumns = buildFileColumns("file")
View Source
var FileErrors = &fileErrors{
	ErrUniquePkMainFile: &UniqueConstraintError{
		schema:  "",
		table:   "file",
		columns: []string{"id"},
		s:       "pk_main_file",
	},
}
View Source
var Files = sqlite.NewTablex[*File, FileSlice, *FileSetter]("", "file")

Files contains methods to work with the file table

View Source
var ItemColumns = buildItemColumns("item")
View Source
var ItemErrors = &itemErrors{
	ErrUniquePkMainItem: &UniqueConstraintError{
		schema:  "",
		table:   "item",
		columns: []string{"id"},
		s:       "pk_main_item",
	},
}
View Source
var Items = sqlite.NewTablex[*Item, ItemSlice, *ItemSetter]("", "item")

Items contains methods to work with the item table

View Source
var Preload = getPreloaders()
View Source
var SchemaMigrationColumns = buildSchemaMigrationColumns("schema_migrations")
View Source
var SchemaMigrationErrors = &schemaMigrationErrors{
	ErrUniquePkMainSchemaMigrations: &UniqueConstraintError{
		schema:  "",
		table:   "schema_migrations",
		columns: []string{"version"},
		s:       "pk_main_schema_migrations",
	},
}
View Source
var SchemaMigrations = sqlite.NewTablex[*SchemaMigration, SchemaMigrationSlice, *SchemaMigrationSetter]("", "schema_migrations")

SchemaMigrations contains methods to work with the schema_migrations table

View Source
var TableNames = struct {
	Credentials      string
	Files            string
	Items            string
	SchemaMigrations string
	Users            string
}{
	Credentials:      "credential",
	Files:            "file",
	Items:            "item",
	SchemaMigrations: "schema_migrations",
	Users:            "user",
}
View Source
var UserColumns = buildUserColumns("user")
View Source
var UserErrors = &userErrors{
	ErrUniquePkMainUser: &UniqueConstraintError{
		schema:  "",
		table:   "user",
		columns: []string{"id"},
		s:       "pk_main_user",
	},
}
View Source
var Users = sqlite.NewTablex[*User, UserSlice, *UserSetter]("", "user")

Users contains methods to work with the user table

Functions

func CredentialExists

func CredentialExists(ctx context.Context, exec bob.Executor, CredIDPK string) (bool, error)

CredentialExists checks the presence of a single record by primary key

func FileExists

func FileExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error)

FileExists checks the presence of a single record by primary key

func ItemExists

func ItemExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error)

ItemExists checks the presence of a single record by primary key

func SchemaMigrationExists

func SchemaMigrationExists(ctx context.Context, exec bob.Executor, VersionPK string) (bool, error)

SchemaMigrationExists checks the presence of a single record by primary key

func UserExists

func UserExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error)

UserExists checks the presence of a single record by primary key

func Where

func Where[Q sqlite.Filterable]() struct {
	Credentials      credentialWhere[Q]
	Files            fileWhere[Q]
	Items            itemWhere[Q]
	SchemaMigrations schemaMigrationWhere[Q]
	Users            userWhere[Q]
}

Types

type Credential

type Credential struct {
	CredID                string           `db:"cred_id,pk" `
	CredPublicKey         []byte           `db:"cred_public_key" `
	SignCount             int32            `db:"sign_count" `
	Transports            sql.Null[string] `db:"transports" `
	UserVerified          sql.Null[bool]   `db:"user_verified" `
	BackupEligible        sql.Null[bool]   `db:"backup_eligible" `
	BackupState           sql.Null[bool]   `db:"backup_state" `
	AttestationObject     sql.Null[[]byte] `db:"attestation_object" `
	AttestationClientData sql.Null[[]byte] `db:"attestation_client_data" `
	CreatedAt             time.Time        `db:"created_at" `
	LastUsed              time.Time        `db:"last_used" `
	UserID                int32            `db:"user_id" `

	R credentialR `db:"-" `
}

Credential is an object representing the database table.

func FindCredential

func FindCredential(ctx context.Context, exec bob.Executor, CredIDPK string, cols ...string) (*Credential, error)

FindCredential retrieves a single record by primary key If cols is empty Find will return all columns.

func (*Credential) AfterQueryHook

func (o *Credential) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after Credential is retrieved from the database

func (*Credential) AttachUser

func (credential0 *Credential) AttachUser(ctx context.Context, exec bob.Executor, user1 *User) error

func (*Credential) Delete

func (o *Credential) Delete(ctx context.Context, exec bob.Executor) error

Delete deletes a single Credential record with an executor

func (*Credential) InsertUser

func (credential0 *Credential) InsertUser(ctx context.Context, exec bob.Executor, related *UserSetter) error

func (*Credential) LoadUser

func (o *Credential) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the credential's User into the .R struct

func (*Credential) Preload

func (o *Credential) Preload(name string, retrieved any) error

func (*Credential) Reload

func (o *Credential) Reload(ctx context.Context, exec bob.Executor) error

Reload refreshes the Credential using the executor

func (*Credential) Update

func (o *Credential) Update(ctx context.Context, exec bob.Executor, s *CredentialSetter) error

Update uses an executor to update the Credential

func (*Credential) User

func (o *Credential) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

User starts a query for related objects on user

type CredentialSetter

type CredentialSetter struct {
	CredID                *string           `db:"cred_id,pk" `
	CredPublicKey         *[]byte           `db:"cred_public_key" `
	SignCount             *int32            `db:"sign_count" `
	Transports            *sql.Null[string] `db:"transports" `
	UserVerified          *sql.Null[bool]   `db:"user_verified" `
	BackupEligible        *sql.Null[bool]   `db:"backup_eligible" `
	BackupState           *sql.Null[bool]   `db:"backup_state" `
	AttestationObject     *sql.Null[[]byte] `db:"attestation_object" `
	AttestationClientData *sql.Null[[]byte] `db:"attestation_client_data" `
	CreatedAt             *time.Time        `db:"created_at" `
	LastUsed              *time.Time        `db:"last_used" `
	UserID                *int32            `db:"user_id" `
}

CredentialSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included

func (*CredentialSetter) Apply

func (s *CredentialSetter) Apply(q *dialect.InsertQuery)

func (CredentialSetter) Expressions

func (s CredentialSetter) Expressions(prefix ...string) []bob.Expression

func (CredentialSetter) Overwrite

func (s CredentialSetter) Overwrite(t *Credential)

func (CredentialSetter) SetColumns

func (s CredentialSetter) SetColumns() []string

func (CredentialSetter) UpdateMod

func (s CredentialSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]

type CredentialSlice

type CredentialSlice []*Credential

CredentialSlice is an alias for a slice of pointers to Credential. This should almost always be used instead of []*Credential.

func (CredentialSlice) AfterQueryHook

func (o CredentialSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after CredentialSlice is retrieved from the database

func (CredentialSlice) DeleteAll

func (o CredentialSlice) DeleteAll(ctx context.Context, exec bob.Executor) error

func (CredentialSlice) DeleteMod

func (o CredentialSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]

DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"

func (CredentialSlice) LoadUser

func (os CredentialSlice) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the credential's User into the .R struct

func (CredentialSlice) ReloadAll

func (o CredentialSlice) ReloadAll(ctx context.Context, exec bob.Executor) error

func (CredentialSlice) UpdateAll

func (o CredentialSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals CredentialSetter) error

func (CredentialSlice) UpdateMod

func (o CredentialSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]

UpdateMod modifies an update query with "WHERE primary_key IN (o...)"

func (CredentialSlice) User

func (os CredentialSlice) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

type CredentialsQuery

type CredentialsQuery = *sqlite.ViewQuery[*Credential, CredentialSlice]

CredentialsQuery is a query on the credential table

type File

type File struct {
	ID     int32  `db:"id,pk" `
	Name   string `db:"name" `
	Data   []byte `db:"data" `
	UserID int32  `db:"user_id" `

	R fileR `db:"-" `
}

File is an object representing the database table.

func FindFile

func FindFile(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*File, error)

FindFile retrieves a single record by primary key If cols is empty Find will return all columns.

func (*File) AfterQueryHook

func (o *File) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after File is retrieved from the database

func (*File) AttachProfilePictureUsers

func (file0 *File) AttachProfilePictureUsers(ctx context.Context, exec bob.Executor, related ...*User) error

func (*File) AttachUser

func (file0 *File) AttachUser(ctx context.Context, exec bob.Executor, user1 *User) error

func (*File) Delete

func (o *File) Delete(ctx context.Context, exec bob.Executor) error

Delete deletes a single File record with an executor

func (*File) InsertProfilePictureUsers

func (file0 *File) InsertProfilePictureUsers(ctx context.Context, exec bob.Executor, related ...*UserSetter) error

func (*File) InsertUser

func (file0 *File) InsertUser(ctx context.Context, exec bob.Executor, related *UserSetter) error

func (*File) LoadProfilePictureUsers

func (o *File) LoadProfilePictureUsers(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadProfilePictureUsers loads the file's ProfilePictureUsers into the .R struct

func (*File) LoadUser

func (o *File) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the file's User into the .R struct

func (*File) Preload

func (o *File) Preload(name string, retrieved any) error

func (*File) ProfilePictureUsers

func (o *File) ProfilePictureUsers(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

ProfilePictureUsers starts a query for related objects on user

func (*File) Reload

func (o *File) Reload(ctx context.Context, exec bob.Executor) error

Reload refreshes the File using the executor

func (*File) Update

func (o *File) Update(ctx context.Context, exec bob.Executor, s *FileSetter) error

Update uses an executor to update the File

func (*File) User

func (o *File) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

User starts a query for related objects on user

type FileSetter

type FileSetter struct {
	ID     *int32  `db:"id,pk" `
	Name   *string `db:"name" `
	Data   *[]byte `db:"data" `
	UserID *int32  `db:"user_id" `
}

FileSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included

func (*FileSetter) Apply

func (s *FileSetter) Apply(q *dialect.InsertQuery)

func (FileSetter) Expressions

func (s FileSetter) Expressions(prefix ...string) []bob.Expression

func (FileSetter) Overwrite

func (s FileSetter) Overwrite(t *File)

func (FileSetter) SetColumns

func (s FileSetter) SetColumns() []string

func (FileSetter) UpdateMod

func (s FileSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]

type FileSlice

type FileSlice []*File

FileSlice is an alias for a slice of pointers to File. This should almost always be used instead of []*File.

func (FileSlice) AfterQueryHook

func (o FileSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after FileSlice is retrieved from the database

func (FileSlice) DeleteAll

func (o FileSlice) DeleteAll(ctx context.Context, exec bob.Executor) error

func (FileSlice) DeleteMod

func (o FileSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]

DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"

func (FileSlice) LoadProfilePictureUsers

func (os FileSlice) LoadProfilePictureUsers(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadProfilePictureUsers loads the file's ProfilePictureUsers into the .R struct

func (FileSlice) LoadUser

func (os FileSlice) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the file's User into the .R struct

func (FileSlice) ProfilePictureUsers

func (os FileSlice) ProfilePictureUsers(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

func (FileSlice) ReloadAll

func (o FileSlice) ReloadAll(ctx context.Context, exec bob.Executor) error

func (FileSlice) UpdateAll

func (o FileSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals FileSetter) error

func (FileSlice) UpdateMod

func (o FileSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]

UpdateMod modifies an update query with "WHERE primary_key IN (o...)"

func (FileSlice) User

func (os FileSlice) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

type FilesQuery

type FilesQuery = *sqlite.ViewQuery[*File, FileSlice]

FilesQuery is a query on the file table

type Item

type Item struct {
	ID          int32     `db:"id,pk" `
	Name        string    `db:"name" `
	Added       time.Time `db:"added" `
	Description string    `db:"description" `
	Price       float32   `db:"price" `
	Quantity    int32     `db:"quantity" `
	UserID      int32     `db:"user_id" `

	R itemR `db:"-" `
}

Item is an object representing the database table.

func FindItem

func FindItem(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*Item, error)

FindItem retrieves a single record by primary key If cols is empty Find will return all columns.

func (*Item) AfterQueryHook

func (o *Item) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after Item is retrieved from the database

func (*Item) AttachUser

func (item0 *Item) AttachUser(ctx context.Context, exec bob.Executor, user1 *User) error

func (*Item) Delete

func (o *Item) Delete(ctx context.Context, exec bob.Executor) error

Delete deletes a single Item record with an executor

func (*Item) InsertUser

func (item0 *Item) InsertUser(ctx context.Context, exec bob.Executor, related *UserSetter) error

func (*Item) LoadUser

func (o *Item) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the item's User into the .R struct

func (*Item) Preload

func (o *Item) Preload(name string, retrieved any) error

func (*Item) Reload

func (o *Item) Reload(ctx context.Context, exec bob.Executor) error

Reload refreshes the Item using the executor

func (*Item) Update

func (o *Item) Update(ctx context.Context, exec bob.Executor, s *ItemSetter) error

Update uses an executor to update the Item

func (*Item) User

func (o *Item) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

User starts a query for related objects on user

type ItemSetter

type ItemSetter struct {
	ID          *int32     `db:"id,pk" `
	Name        *string    `db:"name" `
	Added       *time.Time `db:"added" `
	Description *string    `db:"description" `
	Price       *float32   `db:"price" `
	Quantity    *int32     `db:"quantity" `
	UserID      *int32     `db:"user_id" `
}

ItemSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included

func (*ItemSetter) Apply

func (s *ItemSetter) Apply(q *dialect.InsertQuery)

func (ItemSetter) Expressions

func (s ItemSetter) Expressions(prefix ...string) []bob.Expression

func (ItemSetter) Overwrite

func (s ItemSetter) Overwrite(t *Item)

func (ItemSetter) SetColumns

func (s ItemSetter) SetColumns() []string

func (ItemSetter) UpdateMod

func (s ItemSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]

type ItemSlice

type ItemSlice []*Item

ItemSlice is an alias for a slice of pointers to Item. This should almost always be used instead of []*Item.

func (ItemSlice) AfterQueryHook

func (o ItemSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after ItemSlice is retrieved from the database

func (ItemSlice) DeleteAll

func (o ItemSlice) DeleteAll(ctx context.Context, exec bob.Executor) error

func (ItemSlice) DeleteMod

func (o ItemSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]

DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"

func (ItemSlice) LoadUser

func (os ItemSlice) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadUser loads the item's User into the .R struct

func (ItemSlice) ReloadAll

func (o ItemSlice) ReloadAll(ctx context.Context, exec bob.Executor) error

func (ItemSlice) UpdateAll

func (o ItemSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ItemSetter) error

func (ItemSlice) UpdateMod

func (o ItemSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]

UpdateMod modifies an update query with "WHERE primary_key IN (o...)"

func (ItemSlice) User

func (os ItemSlice) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery

type ItemsQuery

type ItemsQuery = *sqlite.ViewQuery[*Item, ItemSlice]

ItemsQuery is a query on the item table

type SchemaMigration

type SchemaMigration struct {
	Version string `db:"version,pk" `
}

SchemaMigration is an object representing the database table.

func FindSchemaMigration

func FindSchemaMigration(ctx context.Context, exec bob.Executor, VersionPK string, cols ...string) (*SchemaMigration, error)

FindSchemaMigration retrieves a single record by primary key If cols is empty Find will return all columns.

func (*SchemaMigration) AfterQueryHook

func (o *SchemaMigration) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after SchemaMigration is retrieved from the database

func (*SchemaMigration) Delete

func (o *SchemaMigration) Delete(ctx context.Context, exec bob.Executor) error

Delete deletes a single SchemaMigration record with an executor

func (*SchemaMigration) Reload

func (o *SchemaMigration) Reload(ctx context.Context, exec bob.Executor) error

Reload refreshes the SchemaMigration using the executor

func (*SchemaMigration) Update

Update uses an executor to update the SchemaMigration

type SchemaMigrationSetter

type SchemaMigrationSetter struct {
	Version *string `db:"version,pk" `
}

SchemaMigrationSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included

func (*SchemaMigrationSetter) Apply

func (SchemaMigrationSetter) Expressions

func (s SchemaMigrationSetter) Expressions(prefix ...string) []bob.Expression

func (SchemaMigrationSetter) Overwrite

func (s SchemaMigrationSetter) Overwrite(t *SchemaMigration)

func (SchemaMigrationSetter) SetColumns

func (s SchemaMigrationSetter) SetColumns() []string

func (SchemaMigrationSetter) UpdateMod

type SchemaMigrationSlice

type SchemaMigrationSlice []*SchemaMigration

SchemaMigrationSlice is an alias for a slice of pointers to SchemaMigration. This should almost always be used instead of []*SchemaMigration.

func (SchemaMigrationSlice) AfterQueryHook

func (o SchemaMigrationSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after SchemaMigrationSlice is retrieved from the database

func (SchemaMigrationSlice) DeleteAll

func (o SchemaMigrationSlice) DeleteAll(ctx context.Context, exec bob.Executor) error

func (SchemaMigrationSlice) DeleteMod

DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"

func (SchemaMigrationSlice) ReloadAll

func (o SchemaMigrationSlice) ReloadAll(ctx context.Context, exec bob.Executor) error

func (SchemaMigrationSlice) UpdateAll

func (SchemaMigrationSlice) UpdateMod

UpdateMod modifies an update query with "WHERE primary_key IN (o...)"

type SchemaMigrationsQuery

type SchemaMigrationsQuery = *sqlite.ViewQuery[*SchemaMigration, SchemaMigrationSlice]

SchemaMigrationsQuery is a query on the schema_migrations table

type UniqueConstraintError

type UniqueConstraintError struct {
	// contains filtered or unexported fields
}

func (*UniqueConstraintError) Error

func (e *UniqueConstraintError) Error() string

func (*UniqueConstraintError) Is

func (e *UniqueConstraintError) Is(target error) bool

type User

type User struct {
	ID               int32           `db:"id,pk" `
	Username         string          `db:"username" `
	Password         string          `db:"password" `
	ProfilePictureID sql.Null[int32] `db:"profile_picture_id" `
	WebauthnID       string          `db:"webauthn_id" `

	R userR `db:"-" `
}

User is an object representing the database table.

func FindUser

func FindUser(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*User, error)

FindUser retrieves a single record by primary key If cols is empty Find will return all columns.

func (*User) AfterQueryHook

func (o *User) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after User is retrieved from the database

func (*User) AttachCredentials

func (user0 *User) AttachCredentials(ctx context.Context, exec bob.Executor, related ...*Credential) error

func (*User) AttachFiles

func (user0 *User) AttachFiles(ctx context.Context, exec bob.Executor, related ...*File) error

func (*User) AttachItems

func (user0 *User) AttachItems(ctx context.Context, exec bob.Executor, related ...*Item) error

func (*User) AttachProfilePictureFile

func (user0 *User) AttachProfilePictureFile(ctx context.Context, exec bob.Executor, file1 *File) error

func (*User) Credentials

func (o *User) Credentials(mods ...bob.Mod[*dialect.SelectQuery]) CredentialsQuery

Credentials starts a query for related objects on credential

func (*User) Delete

func (o *User) Delete(ctx context.Context, exec bob.Executor) error

Delete deletes a single User record with an executor

func (*User) Files

func (o *User) Files(mods ...bob.Mod[*dialect.SelectQuery]) FilesQuery

Files starts a query for related objects on file

func (*User) InsertCredentials

func (user0 *User) InsertCredentials(ctx context.Context, exec bob.Executor, related ...*CredentialSetter) error

func (*User) InsertFiles

func (user0 *User) InsertFiles(ctx context.Context, exec bob.Executor, related ...*FileSetter) error

func (*User) InsertItems

func (user0 *User) InsertItems(ctx context.Context, exec bob.Executor, related ...*ItemSetter) error

func (*User) InsertProfilePictureFile

func (user0 *User) InsertProfilePictureFile(ctx context.Context, exec bob.Executor, related *FileSetter) error

func (*User) Items

func (o *User) Items(mods ...bob.Mod[*dialect.SelectQuery]) ItemsQuery

Items starts a query for related objects on item

func (*User) LoadCredentials

func (o *User) LoadCredentials(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadCredentials loads the user's Credentials into the .R struct

func (*User) LoadFiles

func (o *User) LoadFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadFiles loads the user's Files into the .R struct

func (*User) LoadItems

func (o *User) LoadItems(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadItems loads the user's Items into the .R struct

func (*User) LoadProfilePictureFile

func (o *User) LoadProfilePictureFile(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadProfilePictureFile loads the user's ProfilePictureFile into the .R struct

func (*User) Preload

func (o *User) Preload(name string, retrieved any) error

func (*User) ProfilePictureFile

func (o *User) ProfilePictureFile(mods ...bob.Mod[*dialect.SelectQuery]) FilesQuery

ProfilePictureFile starts a query for related objects on file

func (*User) Reload

func (o *User) Reload(ctx context.Context, exec bob.Executor) error

Reload refreshes the User using the executor

func (*User) Update

func (o *User) Update(ctx context.Context, exec bob.Executor, s *UserSetter) error

Update uses an executor to update the User

type UserSetter

type UserSetter struct {
	ID               *int32           `db:"id,pk" `
	Username         *string          `db:"username" `
	Password         *string          `db:"password" `
	ProfilePictureID *sql.Null[int32] `db:"profile_picture_id" `
	WebauthnID       *string          `db:"webauthn_id" `
}

UserSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included

func (*UserSetter) Apply

func (s *UserSetter) Apply(q *dialect.InsertQuery)

func (UserSetter) Expressions

func (s UserSetter) Expressions(prefix ...string) []bob.Expression

func (UserSetter) Overwrite

func (s UserSetter) Overwrite(t *User)

func (UserSetter) SetColumns

func (s UserSetter) SetColumns() []string

func (UserSetter) UpdateMod

func (s UserSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]

type UserSlice

type UserSlice []*User

UserSlice is an alias for a slice of pointers to User. This should almost always be used instead of []*User.

func (UserSlice) AfterQueryHook

func (o UserSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error

AfterQueryHook is called after UserSlice is retrieved from the database

func (UserSlice) Credentials

func (os UserSlice) Credentials(mods ...bob.Mod[*dialect.SelectQuery]) CredentialsQuery

func (UserSlice) DeleteAll

func (o UserSlice) DeleteAll(ctx context.Context, exec bob.Executor) error

func (UserSlice) DeleteMod

func (o UserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]

DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"

func (UserSlice) Files

func (os UserSlice) Files(mods ...bob.Mod[*dialect.SelectQuery]) FilesQuery

func (UserSlice) Items

func (os UserSlice) Items(mods ...bob.Mod[*dialect.SelectQuery]) ItemsQuery

func (UserSlice) LoadCredentials

func (os UserSlice) LoadCredentials(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadCredentials loads the user's Credentials into the .R struct

func (UserSlice) LoadFiles

func (os UserSlice) LoadFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadFiles loads the user's Files into the .R struct

func (UserSlice) LoadItems

func (os UserSlice) LoadItems(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadItems loads the user's Items into the .R struct

func (UserSlice) LoadProfilePictureFile

func (os UserSlice) LoadProfilePictureFile(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error

LoadProfilePictureFile loads the user's ProfilePictureFile into the .R struct

func (UserSlice) ProfilePictureFile

func (os UserSlice) ProfilePictureFile(mods ...bob.Mod[*dialect.SelectQuery]) FilesQuery

func (UserSlice) ReloadAll

func (o UserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error

func (UserSlice) UpdateAll

func (o UserSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals UserSetter) error

func (UserSlice) UpdateMod

func (o UserSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]

UpdateMod modifies an update query with "WHERE primary_key IN (o...)"

type UsersQuery

type UsersQuery = *sqlite.ViewQuery[*User, UserSlice]

UsersQuery is a query on the user table

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL