sqlite

package
v0.42.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Case

SQL: CASE WHEN a THEN b ELSE c END Go: sqlite.Case().When("a", "b").Else("c")

func Delete

func Delete(queryMods ...bob.Mod[*dialect.DeleteQuery]) bob.BaseQuery[*dialect.DeleteQuery]

func F

func F(name string, args ...any) mods.Moddable[*dialect.Function]

F creates a function expression with the given name and args

SQL: generate_series(1, 3)
Go: sqlite.F("generate_series", 1, 3)

func Insert

func Insert(queryMods ...bob.Mod[*dialect.InsertQuery]) bob.BaseQuery[*dialect.InsertQuery]

func RawQuery

func RawQuery(q string, args ...any) bob.BaseQuery[expr.Clause]

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]

func UseSchema

func UseSchema(ctx context.Context, schema string) context.Context

UseSchema modifies a context to add a schema that will be used when a tablle/view was generated with an empty schema

func Values

func Values(queryMods ...bob.Mod[*dialect.ValuesQuery]) bob.BaseQuery[*dialect.ValuesQuery]

func WhereAnd

func WhereAnd[Q Filterable](whereMods ...mods.Where[Q]) mods.Where[Q]

func WhereOr

func WhereOr[Q Filterable](whereMods ...mods.Where[Q]) mods.Where[Q]

Types

type Expression

type Expression = dialect.Expression

func And

func And(args ...bob.Expression) Expression

SQL: a AND b AND c Go: sqlite.And("a", "b", "c")

func Arg

func Arg(args ...any) Expression

SQL: $1, $2, $3 Go: sqlite.Args("a", "b", "c")

func ArgGroup

func ArgGroup(args ...any) Expression

SQL: ($1, $2, $3) Go: sqlite.ArgGroup("a", "b", "c")

func Cast

func Cast(exp bob.Expression, typname string) Expression

SQL: CAST(a AS int) Go: psql.Cast("a", "int")

func Concat

func Concat(args ...bob.Expression) Expression

SQL: a || b || c Go: sqlite.Concat("a", "b", "c")

func Group

func Group(exps ...bob.Expression) Expression

SQL: (a, b) Go: sqlite.Group("a", "b")

func Not

func Not(exp bob.Expression) Expression

SQL: NOT true Go: sqlite.Not("true")

func Or

func Or(args ...bob.Expression) Expression

SQL: a OR b OR c Go: sqlite.Or("a", "b", "c")

func Placeholder

func Placeholder(n uint) Expression

SQL: $1, $2, $3 Go: sqlite.Placeholder(3)

func Quote

func Quote(ss ...string) Expression

SQL: "table"."column" Go: sqlite.Quote("table", "column")

func Raw

func Raw(query string, args ...any) Expression

SQL: where a = $1 Go: sqlite.Raw("where a = ?", "something")

func S

func S(s string) Expression

S creates a string literal SQL: 'a string' Go: sqlite.S("a string")

type Filterable

type Filterable interface {
	AppendWhere(...any)
}

type PreloadOption

type PreloadOption = orm.PreloadOption[*dialect.SelectQuery]

Modifies preloading relationships

func PreloadAs

func PreloadAs(alias string) PreloadOption

func PreloadExcept

func PreloadExcept(cols ...string) PreloadOption

func PreloadOnly

func PreloadOnly(cols ...string) PreloadOption

func PreloadWhere

func PreloadWhere(f ...func(from, to string) []bob.Expression) PreloadOption

type PreloadRel

type PreloadRel = orm.PreloadRel[Expression]

type PreloadSettings

type PreloadSettings = orm.PreloadSettings[*dialect.SelectQuery]

Settings for preloading relationships

type PreloadSide

type PreloadSide = orm.PreloadSide[Expression]

type Preloader

type Preloader = orm.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

func Preload[T orm.Preloadable, Ts ~[]T](rel orm.PreloadRel[Expression], cols []string, opts ...PreloadOption) Preloader

type Table

type Table[T any, Tslice ~[]T, Tset setter[T], C bob.Expression] struct {
	*View[T, Tslice, C]

	BeforeInsertHooks bob.Hooks[Tset, bob.SkipModelHooksKey]
	AfterInsertHooks  bob.Hooks[Tslice, bob.SkipModelHooksKey]

	BeforeUpdateHooks bob.Hooks[Tslice, bob.SkipModelHooksKey]
	AfterUpdateHooks  bob.Hooks[Tslice, bob.SkipModelHooksKey]

	BeforeDeleteHooks bob.Hooks[Tslice, bob.SkipModelHooksKey]
	AfterDeleteHooks  bob.Hooks[Tslice, bob.SkipModelHooksKey]

	InsertQueryHooks bob.Hooks[*dialect.InsertQuery, bob.SkipQueryHooksKey]
	UpdateQueryHooks bob.Hooks[*dialect.UpdateQuery, bob.SkipQueryHooksKey]
	DeleteQueryHooks bob.Hooks[*dialect.DeleteQuery, bob.SkipQueryHooksKey]
	// contains filtered or unexported fields
}

The table contains extract information from the struct and contains caches ???

func NewTable

func NewTable[T any, Tset setter[T], C bob.Expression](schema, tableName string, columns C) *Table[T, []T, Tset, C]

func NewTablex

func NewTablex[T any, Tslice ~[]T, Tset setter[T], C bob.Expression](schema, tableName string, columns C) *Table[T, Tslice, Tset, C]

func (*Table[T, Tslice, Tset, C]) Delete

func (t *Table[T, Tslice, Tset, C]) Delete(queryMods ...bob.Mod[*dialect.DeleteQuery]) *ormDeleteQuery[T, Tslice]

Starts a Delete query for this table

func (*Table[T, Tslice, Tset, C]) Insert

func (t *Table[T, Tslice, Tset, C]) Insert(queryMods ...bob.Mod[*dialect.InsertQuery]) *ormInsertQuery[T, Tslice]

Starts an insert query for this table

func (*Table[T, Tslice, Tset, C]) PrimaryKey

func (t *Table[T, Tslice, Tset, C]) PrimaryKey() expr.ColumnsExpr

Returns the primary key columns for this table.

func (*Table[T, Tslice, Tset, C]) Update

func (t *Table[T, Tslice, Tset, C]) Update(queryMods ...bob.Mod[*dialect.UpdateQuery]) *ormUpdateQuery[T, Tslice]

Starts an Update query for this table

type View

type View[T any, Tslice ~[]T, C bob.Expression] struct {
	Columns C

	AfterSelectHooks bob.Hooks[Tslice, bob.SkipModelHooksKey]
	SelectQueryHooks bob.Hooks[*dialect.SelectQuery, bob.SkipQueryHooksKey]
	// contains filtered or unexported fields
}

func NewView

func NewView[T any, C bob.Expression](schema, tableName string, columns C) *View[T, []T, C]

func NewViewx

func NewViewx[T any, Tslice ~[]T, C bob.Expression](schema, tableName string, columns C) *View[T, Tslice, C]

func (*View[T, Tslice, C]) Alias

func (v *View[T, Tslice, C]) Alias() string

func (*View[T, Tslice, C]) ColumnsExpr

func (v *View[T, Tslice, C]) ColumnsExpr() expr.ColumnsExpr

Returns a column list

func (*View[T, Tslice, C]) Name

func (v *View[T, Tslice, C]) Name() Expression

func (*View[T, Tslice, C]) NameAs

func (v *View[T, Tslice, C]) NameAs() bob.Expression

func (*View[T, Tslice, C]) Query

func (v *View[T, Tslice, C]) Query(queryMods ...bob.Mod[*dialect.SelectQuery]) *ViewQuery[T, Tslice]

Starts a select query

type ViewQuery

type ViewQuery[T any, Ts ~[]T] struct {
	orm.Query[*dialect.SelectQuery, T, Ts, bob.SliceTransformer[T, Ts]]
}

func (*ViewQuery[T, Tslice]) Count

func (v *ViewQuery[T, Tslice]) Count(ctx context.Context, exec bob.Executor) (int64, error)

Count the number of matching rows

func (*ViewQuery[T, Tslice]) Exists

func (v *ViewQuery[T, Tslice]) Exists(ctx context.Context, exec bob.Executor) (bool, error)

Exists checks if there is any matching row

type WhereMod

type WhereMod[Q Filterable, C any] struct {
	// contains filtered or unexported fields
}

func Where

func Where[Q Filterable, C any](name Expression) WhereMod[Q, C]

func (WhereMod[Q, C]) EQ

func (w WhereMod[Q, C]) EQ(val C) mods.Where[Q]

func (WhereMod[Q, C]) GT

func (w WhereMod[Q, C]) GT(val C) mods.Where[Q]

func (WhereMod[Q, C]) GTE

func (w WhereMod[Q, C]) GTE(val C) mods.Where[Q]

func (WhereMod[Q, C]) In

func (w WhereMod[Q, C]) In(slice ...C) mods.Where[Q]

func (WhereMod[Q, C]) LT

func (w WhereMod[Q, C]) LT(val C) mods.Where[Q]

func (WhereMod[Q, C]) LTE

func (w WhereMod[Q, C]) LTE(val C) mods.Where[Q]

func (WhereMod[Q, C]) Like

func (w WhereMod[Q, C]) Like(val C) mods.Where[Q]

func (WhereMod[Q, C]) NE

func (w WhereMod[Q, C]) NE(val C) mods.Where[Q]

func (WhereMod[Q, C]) NotIn

func (w WhereMod[Q, C]) NotIn(slice ...C) mods.Where[Q]

type WhereNullMod

type WhereNullMod[Q interface {
	AppendWhere(e ...any)
}, C any] struct {
	WhereMod[Q, C]
}

func WhereNull

func WhereNull[Q Filterable, C any](name Expression) WhereNullMod[Q, C]

func (WhereNullMod[Q, C]) IsNotNull

func (w WhereNullMod[Q, C]) IsNotNull() mods.Where[Q]

func (WhereNullMod[Q, C]) IsNull

func (w WhereNullMod[Q, C]) IsNull() mods.Where[Q]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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