models

package
v0.0.0-...-66353ae Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncFail = errors.New("models: failed to synchronize data after insert")

ErrSyncFail occurs during insert when the record could not be retrieved in order to populate default value information. This usually happens when LastInsertId fails or there was a primary key configuration that was not resolvable.

View Source
var ProductColumns = struct {
	ID          string
	Name        string
	Description string
	Price       string
	Created     string
	Modified    string
}{
	ID:          "id",
	Name:        "name",
	Description: "description",
	Price:       "price",
	Created:     "created",
	Modified:    "modified",
}
View Source
var ProductRels = struct {
}{}

ProductRels is where relationship names are stored.

View Source
var ProductTableColumns = struct {
	ID          string
	Name        string
	Description string
	Price       string
	Created     string
	Modified    string
}{
	ID:          "products.id",
	Name:        "products.name",
	Description: "products.description",
	Price:       "products.price",
	Created:     "products.created",
	Modified:    "products.modified",
}
View Source
var ProductWhere = struct {
	ID          whereHelperint
	Name        whereHelperstring
	Description whereHelperstring
	Price       whereHelperint
	Created     whereHelpertime_Time
	Modified    whereHelpertime_Time
}{
	ID:          whereHelperint{/* contains filtered or unexported fields */},
	Name:        whereHelperstring{/* contains filtered or unexported fields */},
	Description: whereHelperstring{/* contains filtered or unexported fields */},
	Price:       whereHelperint{/* contains filtered or unexported fields */},
	Created:     whereHelpertime_Time{/* contains filtered or unexported fields */},
	Modified:    whereHelpertime_Time{/* contains filtered or unexported fields */},
}
View Source
var TableNames = struct {
	Products string
	Users    string
}{
	Products: "products",
	Users:    "users",
}
View Source
var UserColumns = struct {
	ID       string
	Username string
	Password string
	Email    string
	Name     string
	Gender   string
	Created  string
	Modified string
}{
	ID:       "id",
	Username: "username",
	Password: "password",
	Email:    "email",
	Name:     "name",
	Gender:   "gender",
	Created:  "created",
	Modified: "modified",
}
View Source
var UserRels = struct {
}{}

UserRels is where relationship names are stored.

View Source
var UserTableColumns = struct {
	ID       string
	Username string
	Password string
	Email    string
	Name     string
	Gender   string
	Created  string
	Modified string
}{
	ID:       "users.id",
	Username: "users.username",
	Password: "users.password",
	Email:    "users.email",
	Name:     "users.name",
	Gender:   "users.gender",
	Created:  "users.created",
	Modified: "users.modified",
}
View Source
var UserWhere = struct {
	ID       whereHelperint
	Username whereHelperstring
	Password whereHelperstring
	Email    whereHelperstring
	Name     whereHelperstring
	Gender   whereHelperGenderEnum
	Created  whereHelpertime_Time
	Modified whereHelpertime_Time
}{
	ID:       whereHelperint{/* contains filtered or unexported fields */},
	Username: whereHelperstring{/* contains filtered or unexported fields */},
	Password: whereHelperstring{/* contains filtered or unexported fields */},
	Email:    whereHelperstring{/* contains filtered or unexported fields */},
	Name:     whereHelperstring{/* contains filtered or unexported fields */},
	Gender:   whereHelperGenderEnum{/* contains filtered or unexported fields */},
	Created:  whereHelpertime_Time{/* contains filtered or unexported fields */},
	Modified: whereHelpertime_Time{/* contains filtered or unexported fields */},
}
View Source
var ViewNames = struct {
}{}

Functions

func AddProductHook

func AddProductHook(hookPoint boil.HookPoint, productHook ProductHook)

AddProductHook registers your hook function for all future operations.

func AddUserHook

func AddUserHook(hookPoint boil.HookPoint, userHook UserHook)

AddUserHook registers your hook function for all future operations.

func NewQuery

func NewQuery(mods ...qm.QueryMod) *queries.Query

NewQuery initializes a new Query using the passed in QueryMods

func ProductExists

func ProductExists(ctx context.Context, exec boil.ContextExecutor, iD int) (bool, error)

ProductExists checks if the Product row exists.

func Products

func Products(mods ...qm.QueryMod) productQuery

Products retrieves all the records using an executor.

func UserExists

func UserExists(ctx context.Context, exec boil.ContextExecutor, iD int) (bool, error)

UserExists checks if the User row exists.

func Users

func Users(mods ...qm.QueryMod) userQuery

Users retrieves all the records using an executor.

Types

type GenderEnum

type GenderEnum string
const (
	GenderEnumMale   GenderEnum = "male"
	GenderEnumFemale GenderEnum = "female"
)

Enum values for GenderEnum

func AllGenderEnum

func AllGenderEnum() []GenderEnum

func (GenderEnum) IsValid

func (e GenderEnum) IsValid() error

func (GenderEnum) Ordinal

func (e GenderEnum) Ordinal() int

func (GenderEnum) String

func (e GenderEnum) String() string

type M

type M map[string]interface{}

M type is for providing columns and column values to UpdateAll.

type Product

type Product struct {
	ID          int       `boil:"id" json:"id" toml:"id" yaml:"id"`
	Name        string    `boil:"name" json:"name" toml:"name" yaml:"name"`
	Description string    `boil:"description" json:"description" toml:"description" yaml:"description"`
	Price       int       `boil:"price" json:"price" toml:"price" yaml:"price"`
	Created     time.Time `boil:"created" json:"created" toml:"created" yaml:"created"`
	Modified    time.Time `boil:"modified" json:"modified" toml:"modified" yaml:"modified"`

	R *productR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L productL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}

Product is an object representing the database table.

func FindProduct

func FindProduct(ctx context.Context, exec boil.ContextExecutor, iD int, selectCols ...string) (*Product, error)

FindProduct retrieves a single record by ID with an executor. If selectCols is empty Find will return all columns.

func (*Product) Delete

func (o *Product) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error)

Delete deletes a single Product record with an executor. Delete will match against the primary key column to find the record to delete.

func (*Product) Exists

func (o *Product) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error)

Exists checks if the Product row exists.

func (*Product) Insert

func (o *Product) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error

Insert a single record using an executor. See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.

func (*Product) Reload

func (o *Product) Reload(ctx context.Context, exec boil.ContextExecutor) error

Reload refetches the object from the database using the primary keys with an executor.

func (*Product) Update

func (o *Product) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error)

Update uses an executor to update the Product. See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. Update does not automatically update the record in case of default values. Use .Reload() to refresh the records.

func (*Product) Upsert

func (o *Product) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc) error

Upsert attempts an insert using an executor, and does an update or ignore on conflict. See boil.Columns documentation for how to properly use updateColumns and insertColumns.

type ProductHook

type ProductHook func(context.Context, boil.ContextExecutor, *Product) error

ProductHook is the signature for custom Product hook methods

type ProductSlice

type ProductSlice []*Product

ProductSlice is an alias for a slice of pointers to Product. This should almost always be used instead of []Product.

func (ProductSlice) DeleteAll

func (o ProductSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error)

DeleteAll deletes all rows in the slice, using an executor.

func (*ProductSlice) ReloadAll

func (o *ProductSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error

ReloadAll refetches every row with matching primary key column values and overwrites the original object slice with the newly updated slice.

func (ProductSlice) UpdateAll

func (o ProductSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error)

UpdateAll updates all rows with the specified column values, using an executor.

type UpsertOptionFunc

type UpsertOptionFunc func(o *UpsertOptions)

func UpsertConflictTarget

func UpsertConflictTarget(conflictTarget string) UpsertOptionFunc

func UpsertUpdateSet

func UpsertUpdateSet(updateSet string) UpsertOptionFunc

type UpsertOptions

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

type User

type User struct {
	ID       int        `boil:"id" json:"id" toml:"id" yaml:"id"`
	Username string     `boil:"username" json:"username" toml:"username" yaml:"username"`
	Password string     `boil:"password" json:"password" toml:"password" yaml:"password"`
	Email    string     `boil:"email" json:"email" toml:"email" yaml:"email"`
	Name     string     `boil:"name" json:"name" toml:"name" yaml:"name"`
	Gender   GenderEnum `boil:"gender" json:"gender" toml:"gender" yaml:"gender"`
	Created  time.Time  `boil:"created" json:"created" toml:"created" yaml:"created"`
	Modified time.Time  `boil:"modified" json:"modified" toml:"modified" yaml:"modified"`

	R *userR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L userL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}

User is an object representing the database table.

func FindUser

func FindUser(ctx context.Context, exec boil.ContextExecutor, iD int, selectCols ...string) (*User, error)

FindUser retrieves a single record by ID with an executor. If selectCols is empty Find will return all columns.

func (*User) Delete

func (o *User) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error)

Delete deletes a single User record with an executor. Delete will match against the primary key column to find the record to delete.

func (*User) Exists

func (o *User) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error)

Exists checks if the User row exists.

func (*User) Insert

func (o *User) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error

Insert a single record using an executor. See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.

func (*User) Reload

func (o *User) Reload(ctx context.Context, exec boil.ContextExecutor) error

Reload refetches the object from the database using the primary keys with an executor.

func (*User) Update

func (o *User) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error)

Update uses an executor to update the User. See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. Update does not automatically update the record in case of default values. Use .Reload() to refresh the records.

func (*User) Upsert

func (o *User) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc) error

Upsert attempts an insert using an executor, and does an update or ignore on conflict. See boil.Columns documentation for how to properly use updateColumns and insertColumns.

type UserHook

type UserHook func(context.Context, boil.ContextExecutor, *User) error

UserHook is the signature for custom User hook methods

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) DeleteAll

func (o UserSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error)

DeleteAll deletes all rows in the slice, using an executor.

func (*UserSlice) ReloadAll

func (o *UserSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error

ReloadAll refetches every row with matching primary key column values and overwrites the original object slice with the newly updated slice.

func (UserSlice) UpdateAll

func (o UserSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error)

UpdateAll updates all rows with the specified column values, using an executor.

Jump to

Keyboard shortcuts

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