Documentation ¶
Index ¶
- func Delete(queryMods ...bob.Mod[*dialect.DeleteQuery]) bob.BaseQuery[*dialect.DeleteQuery]
- func F(name string, args ...any) mods.Moddable[*dialect.Function]
- func Insert(queryMods ...bob.Mod[*dialect.InsertQuery]) bob.BaseQuery[*dialect.InsertQuery]
- func RawQuery(q string, args ...any) bob.BaseQuery[expr.Clause]
- func Select(queryMods ...bob.Mod[*dialect.SelectQuery]) bob.BaseQuery[*dialect.SelectQuery]
- func Update(queryMods ...bob.Mod[*dialect.UpdateQuery]) bob.BaseQuery[*dialect.UpdateQuery]
- func WhereAnd[Q Filterable](whereMods ...mods.Where[Q]) mods.Where[Q]
- func WhereOr[Q Filterable](whereMods ...mods.Where[Q]) mods.Where[Q]
- type Expression
- func And(args ...bob.Expression) Expression
- func Arg(args ...any) Expression
- func ArgGroup(args ...any) Expression
- func Concat(args ...bob.Expression) Expression
- func Group(exps ...bob.Expression) Expression
- func Not(exp bob.Expression) Expression
- func Or(args ...bob.Expression) Expression
- func Placeholder(n uint) Expression
- func Quote(ss ...string) Expression
- func Raw(query string, args ...any) Expression
- func S(s string) Expression
- type Filterable
- type Loader
- type PreloadOption
- type PreloadSettings
- type Preloader
- type TQuery
- type Table
- func (t *Table[T, Tslice, Tset]) Delete(ctx context.Context, exec bob.Executor, rows ...T) error
- func (t *Table[T, Tslice, Tset]) DeleteQ(ctx context.Context, exec bob.Executor, ...) *TQuery[*dialect.DeleteQuery, T, Tslice]
- func (t *Table[T, Tslice, Tset]) Insert(ctx context.Context, exec bob.Executor, row Tset) (T, error)
- func (t *Table[T, Tslice, Tset]) InsertMany(ctx context.Context, exec bob.Executor, rows ...Tset) (Tslice, error)
- func (t *Table[T, Tslice, Tset]) InsertQ(ctx context.Context, exec bob.Executor, ...) *TQuery[*dialect.InsertQuery, T, Tslice]
- func (t *Table[T, Tslice, Tset]) Update(ctx context.Context, exec bob.Executor, vals Tset, rows ...T) error
- func (t *Table[T, Tslice, Tset]) UpdateQ(ctx context.Context, exec bob.Executor, ...) *TQuery[*dialect.UpdateQuery, T, Tslice]
- func (t *Table[T, Tslice, Tset]) Upsert(ctx context.Context, exec bob.Executor, updateOnConflict bool, ...) (T, error)
- func (t *Table[T, Tslice, Tset]) UpsertMany(ctx context.Context, exec bob.Executor, updateOnConflict bool, ...) (Tslice, error)
- type View
- func (v *View[T, Tslice]) Columns() orm.Columns
- func (v *View[T, Tslice]) Name(ctx context.Context) Expression
- func (v *View[T, Tslice]) NameAs(ctx context.Context) bob.Expression
- func (v *View[T, Tslice]) Prepare(ctx context.Context, exec bob.Preparer, ...) (bob.QueryStmt[T, Tslice], error)
- func (v *View[T, Tslice]) PrepareQuery(ctx context.Context, exec bob.Preparer, q bob.Query) (bob.QueryStmt[T, Tslice], error)
- func (v *View[T, Tslice]) Query(ctx context.Context, exec bob.Executor, ...) *ViewQuery[T, Tslice]
- type ViewQuery
- func (v *ViewQuery[T, Tslice]) All() (Tslice, error)
- func (v *ViewQuery[T, Tslice]) Count() (int64, error)
- func (v *ViewQuery[T, Tslice]) Cursor() (scan.ICursor[T], error)
- func (v *ViewQuery[T, Tslice]) Exec() (int64, error)
- func (v *ViewQuery[T, Tslice]) Exists() (bool, error)
- func (v *ViewQuery[T, Tslice]) One() (T, error)
- func (v ViewQuery[T, Ts]) WriteQuery(w io.Writer, start int) ([]any, error)
- func (v ViewQuery[T, Ts]) WriteSQL(w io.Writer, _ bob.Dialect, start int) ([]any, error)
- type WhereMod
- func (w WhereMod[Q, C]) EQ(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) GT(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) GTE(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) In(slice ...C) mods.Where[Q]
- func (w WhereMod[Q, C]) LT(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) LTE(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) Like(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) NE(val C) mods.Where[Q]
- func (w WhereMod[Q, C]) NotIn(slice ...C) mods.Where[Q]
- type WhereNullMod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(queryMods ...bob.Mod[*dialect.DeleteQuery]) bob.BaseQuery[*dialect.DeleteQuery]
func F ¶
F creates a function expression with the given name and args
SQL: generate_series(1, 3) Go: mysql.F("generate_series", 1, 3)
func Insert ¶
func Insert(queryMods ...bob.Mod[*dialect.InsertQuery]) bob.BaseQuery[*dialect.InsertQuery]
func Select ¶
func Select(queryMods ...bob.Mod[*dialect.SelectQuery]) bob.BaseQuery[*dialect.SelectQuery]
func Update ¶
func Update(queryMods ...bob.Mod[*dialect.UpdateQuery]) bob.BaseQuery[*dialect.UpdateQuery]
Types ¶
type Expression ¶ added in v0.2.0
type Expression = dialect.Expression
func And ¶
func And(args ...bob.Expression) Expression
SQL: a AND b AND c Go: mysql.And("a", "b", "c")
func ArgGroup ¶ added in v0.15.0
func ArgGroup(args ...any) Expression
SQL: ($1, $2, $3) Go: mysql.ArgGroup("a", "b", "c")
func Concat ¶
func Concat(args ...bob.Expression) Expression
SQL: a || b || c Go: mysql.Concat("a", "b", "c")
func Quote ¶
func Quote(ss ...string) Expression
SQL: "table"."column" Go: mysql.Quote("table", "column")
func Raw ¶
func Raw(query string, args ...any) Expression
SQL: where a = $1 Go: mysql.Raw("where a = ?", "something")
func S ¶
func S(s string) Expression
S creates a string literal SQL: 'a string' Go: mysql.S("a string")
type Filterable ¶ added in v0.15.0
type Filterable interface {
AppendWhere(...any)
}
type Loader ¶ added in v0.15.0
type Loader = internal.Loader[*dialect.SelectQuery]
Loader builds a query mod that makes an extra query after the object is retrieved it can be used to prevent N+1 queries by loading relationships in batches
type PreloadOption ¶ added in v0.15.0
type PreloadOption = internal.PreloadOption[*dialect.SelectQuery]
Modifies preloading relationships
func PreloadAs ¶ added in v0.27.0
func PreloadAs(alias string) PreloadOption
func PreloadExcept ¶ added in v0.20.0
func PreloadExcept(cols ...string) PreloadOption
func PreloadOnly ¶ added in v0.20.0
func PreloadOnly(cols ...string) PreloadOption
func PreloadWhere ¶ added in v0.20.0
func PreloadWhere(f ...func(from, to string) []bob.Expression) PreloadOption
type PreloadSettings ¶ added in v0.19.0
type PreloadSettings = internal.PreloadSettings[*dialect.SelectQuery]
Settings for preloading relationships
type Preloader ¶ added in v0.15.0
type Preloader = internal.Preloader[*dialect.SelectQuery]
Preloader builds a query mod that modifies the original query to retrieve related fields while it can be used as a queryMod, it does not have any direct effect. if using manually, the ApplyPreload method should be called with the query's context AFTER other mods have been applied
func Preload ¶ added in v0.15.0
func Preload[T any, Ts ~[]T](rel orm.Relationship, cols []string, opts ...PreloadOption) Preloader
type TQuery ¶ added in v0.22.0
type TQuery[Q bob.Expression, T any, Ts ~[]T] struct { bob.BaseQuery[Q] // contains filtered or unexported fields }
type Table ¶ added in v0.15.0
type Table[T orm.Table, Tslice ~[]T, Tset setter[T]] struct { *View[T, Tslice] BeforeInsertHooks orm.Hooks[[]Tset, orm.SkipModelHooksKey] AfterInsertHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] BeforeUpsertHooks orm.Hooks[[]Tset, orm.SkipModelHooksKey] AfterUpsertHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] BeforeUpdateHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] AfterUpdateHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] BeforeDeleteHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] AfterDeleteHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] InsertQueryHooks orm.Hooks[*dialect.InsertQuery, orm.SkipQueryHooksKey] UpdateQueryHooks orm.Hooks[*dialect.UpdateQuery, orm.SkipQueryHooksKey] DeleteQueryHooks orm.Hooks[*dialect.DeleteQuery, orm.SkipQueryHooksKey] // contains filtered or unexported fields }
The table contains extract information from the struct and contains caches ???
func (*Table[T, Tslice, Tset]) Delete ¶ added in v0.15.0
Deletes the given model if columns is nil, every column is deleted
func (*Table[T, Tslice, Tset]) DeleteQ ¶ added in v0.22.0
func (t *Table[T, Tslice, Tset]) DeleteQ(ctx context.Context, exec bob.Executor, queryMods ...bob.Mod[*dialect.DeleteQuery]) *TQuery[*dialect.DeleteQuery, T, Tslice]
Starts a delete query for this table
func (*Table[T, Tslice, Tset]) Insert ¶ added in v0.15.0
func (t *Table[T, Tslice, Tset]) Insert(ctx context.Context, exec bob.Executor, row Tset) (T, error)
Insert inserts a row into the table with only the set columns in Tset
func (*Table[T, Tslice, Tset]) InsertMany ¶ added in v0.15.0
func (t *Table[T, Tslice, Tset]) InsertMany(ctx context.Context, exec bob.Executor, rows ...Tset) (Tslice, error)
InsertMany inserts rows into the table with only the set columns in Tset NOTE: Because of the lack of support for RETURNING in MySQL, each row is inserted in a separate query
func (*Table[T, Tslice, Tset]) InsertQ ¶ added in v0.22.0
func (t *Table[T, Tslice, Tset]) InsertQ(ctx context.Context, exec bob.Executor, queryMods ...bob.Mod[*dialect.InsertQuery]) *TQuery[*dialect.InsertQuery, T, Tslice]
Starts an insert query for this table
func (*Table[T, Tslice, Tset]) Update ¶ added in v0.15.0
func (t *Table[T, Tslice, Tset]) Update(ctx context.Context, exec bob.Executor, vals Tset, rows ...T) error
Updates the given model if columns is nil, every non-primary-key column is updated NOTE: values from the DB are not refreshed into the model
func (*Table[T, Tslice, Tset]) UpdateQ ¶ added in v0.22.0
func (t *Table[T, Tslice, Tset]) UpdateQ(ctx context.Context, exec bob.Executor, queryMods ...bob.Mod[*dialect.UpdateQuery]) *TQuery[*dialect.UpdateQuery, T, Tslice]
Starts an update query for this table
func (*Table[T, Tslice, Tset]) Upsert ¶ added in v0.15.0
func (t *Table[T, Tslice, Tset]) Upsert(ctx context.Context, exec bob.Executor, updateOnConflict bool, updateCols []string, row Tset) (T, error)
Uses the setional columns to know what to insert If updateCols is nil, it updates all the columns set in Tset NOTE: Because of the lack of support for RETURNING in MySQL, each row is inserted in a separate query
func (*Table[T, Tslice, Tset]) UpsertMany ¶ added in v0.15.0
func (t *Table[T, Tslice, Tset]) UpsertMany(ctx context.Context, exec bob.Executor, updateOnConflict bool, updateCols []string, rows ...Tset) (Tslice, error)
Uses the setional columns to know what to insert If updateCols is nil, it updates all the columns set in Tset NOTE: Because of the lack of support for RETURNING in MySQL, each row is inserted in a separate query
type View ¶ added in v0.15.0
type View[T any, Tslice ~[]T] struct { AfterSelectHooks orm.Hooks[Tslice, orm.SkipModelHooksKey] SelectQueryHooks orm.Hooks[*dialect.SelectQuery, orm.SkipQueryHooksKey] // contains filtered or unexported fields }
func (*View[T, Tslice]) Name ¶ added in v0.15.0
func (v *View[T, Tslice]) Name(ctx context.Context) Expression
func (*View[T, Tslice]) NameAs ¶ added in v0.15.0
func (v *View[T, Tslice]) NameAs(ctx context.Context) bob.Expression
func (*View[T, Tslice]) Prepare ¶ added in v0.15.0
func (v *View[T, Tslice]) Prepare(ctx context.Context, exec bob.Preparer, queryMods ...bob.Mod[*dialect.SelectQuery]) (bob.QueryStmt[T, Tslice], error)
Prepare a statement that will be mapped to the view's type
type ViewQuery ¶ added in v0.15.0
type ViewQuery[T any, Ts ~[]T] struct { bob.BaseQuery[*dialect.SelectQuery] // contains filtered or unexported fields }
func (ViewQuery[T, Ts]) WriteQuery ¶ added in v0.15.0
it is necessary to override this method to be able to add columns if not set
type WhereMod ¶ added in v0.15.0
type WhereMod[Q Filterable, C any] struct { // contains filtered or unexported fields }
func Where ¶ added in v0.15.0
func Where[Q Filterable, C any](name Expression) WhereMod[Q, C]
type WhereNullMod ¶ added in v0.15.0
func WhereNull ¶ added in v0.15.0
func WhereNull[Q Filterable, C any](name Expression) WhereNullMod[Q, C]
func (WhereNullMod[Q, C]) IsNotNull ¶ added in v0.15.0
func (w WhereNullMod[Q, C]) IsNotNull() mods.Where[Q]
func (WhereNullMod[Q, C]) IsNull ¶ added in v0.15.0
func (w WhereNullMod[Q, C]) IsNull() mods.Where[Q]