Documentation
¶
Index ¶
- Variables
- func UserExists(ctx context.Context, exec bob.Executor, IDPK uuid.UUID) (bool, error)
- func Where[Q psql.Filterable]() struct{ ... }
- type UniqueConstraintError
- type User
- func (o *User) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
- func (o *User) Delete(ctx context.Context, exec bob.Executor) error
- func (o *User) PrimaryKeyVals() bob.Expression
- func (o *User) Reload(ctx context.Context, exec bob.Executor) error
- func (o *User) Update(ctx context.Context, exec bob.Executor, s *UserSetter) error
- type UserSetter
- type UserSlice
- func (o UserSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
- func (o UserSlice) DeleteAll(ctx context.Context, exec bob.Executor) error
- func (o UserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]
- func (o UserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error
- func (o UserSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals UserSetter) error
- func (o UserSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]
- type UsersQuery
Constants ¶
This section is empty.
Variables ¶
var ( SelectWhere = Where[*dialect.SelectQuery]() InsertWhere = Where[*dialect.InsertQuery]() UpdateWhere = Where[*dialect.UpdateQuery]() DeleteWhere = Where[*dialect.DeleteQuery]() )
var ( SelectJoins = getJoins[*dialect.SelectQuery]() UpdateJoins = getJoins[*dialect.UpdateQuery]() DeleteJoins = getJoins[*dialect.DeleteQuery]() )
var ColumnNames = struct {
Users userColumnNames
}{
Users: userColumnNames{
ID: "id",
Name: "name",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
},
}
var ErrUniqueConstraint = &UniqueConstraintError{s: ""}
ErrUniqueConstraint captures all unique constraint errors by explicitly leaving `s` empty.
var TableNames = struct { Users string }{ Users: "users", }
var UserColumns = buildUserColumns("users")
var UserErrors = &userErrors{ ErrUniqueUsersPkey: &UniqueConstraintError{s: "users_pkey"}, }
var Users = psql.NewTablex[*User, UserSlice, *UserSetter]("", "users")
Users contains methods to work with the users table
Functions ¶
func UserExists ¶
UserExists checks the presence of a single record by primary key
func Where ¶
func Where[Q psql.Filterable]() struct { Users userWhere[Q] }
Types ¶
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 uuid.UUID `db:"id,pk" ` Name string `db:"name" ` CreatedAt time.Time `db:"created_at" ` UpdatedAt time.Time `db:"updated_at" ` }
User is an object representing the database table.
func FindUser ¶
func FindUser(ctx context.Context, exec bob.Executor, IDPK uuid.UUID, 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) PrimaryKeyVals ¶
func (o *User) PrimaryKeyVals() bob.Expression
PrimaryKeyVals returns the primary key values of the User
type UserSetter ¶
type UserSetter struct { ID omit.Val[uuid.UUID] `db:"id,pk" ` Name omit.Val[string] `db:"name" ` CreatedAt omit.Val[time.Time] `db:"created_at" ` UpdatedAt omit.Val[time.Time] `db:"updated_at" ` }
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) DeleteMod ¶
func (o UserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]
DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"