selects

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeRelationships

func InitializeRelationships(v any) error

func Load

func Load(tx *sqlx.Tx, v any, relation string) error

func NewSelects

func NewSelects() *selects

Types

type AfterLoader

type AfterLoader interface {
	AfterLoad(ctx context.Context, tx *sqlx.Tx) error
}

type AfterSaver

type AfterSaver interface {
	AfterSave(ctx context.Context, tx *sqlx.Tx) error
}

type BeforeSaver

type BeforeSaver interface {
	BeforeSave(ctx context.Context, tx *sqlx.Tx) error
}

type BelongsTo

type BelongsTo[T models.Model] struct {
	// contains filtered or unexported fields
}

func (*BelongsTo[T]) Initialize

func (r *BelongsTo[T]) Initialize(parent any, field reflect.StructField) error

func (*BelongsTo[T]) Load

func (r *BelongsTo[T]) Load(tx *sqlx.Tx, relations []Relationship) error

func (*BelongsTo) Loaded

func (v *BelongsTo) Loaded() bool

func (*BelongsTo) MarshalJSON

func (v *BelongsTo) MarshalJSON() ([]byte, error)

func (BelongsTo) Subquery added in v0.7.0

func (r BelongsTo) Subquery() *SubBuilder

func (*BelongsTo[T]) Value

func (r *BelongsTo[T]) Value(tx *sqlx.Tx) (T, error)

type Builder

type Builder[T models.Model] struct {
	// contains filtered or unexported fields
}

func From

func From[T models.Model]() *Builder[T]

func New

func New[T models.Model]() *Builder[T]

func NewEmpty

func NewEmpty[T models.Model]() *Builder[T]

func (*Builder[T]) AddGroupBy

func (b *Builder[T]) AddGroupBy(columns ...string) *Builder[T]

func (*Builder[T]) AddSelect

func (b *Builder[T]) AddSelect(columns ...string) *Builder[T]

func (*Builder[T]) AddSelectFunction added in v0.4.1

func (b *Builder[T]) AddSelectFunction(function, column string) *Builder[T]

func (*Builder[T]) AddSelectSubquery

func (b *Builder[T]) AddSelectSubquery(sb QueryBuilder) *Builder[T]

func (*Builder[T]) And

func (b *Builder[T]) And(cb func(wl *WhereList)) *Builder[T]

func (*Builder[T]) Clone added in v0.3.1

func (b *Builder[T]) Clone() *Builder[T]

func (*Builder[T]) Distinct

func (b *Builder[T]) Distinct() *Builder[T]

func (*Builder[T]) Dump

func (b *Builder[T]) Dump() *Builder[T]

func (*Builder[T]) Find

func (b *Builder[T]) Find(tx *sqlx.Tx, primaryKeyValue any) (T, error)

func (*Builder[T]) FindContext

func (b *Builder[T]) FindContext(ctx context.Context, tx *sqlx.Tx, primaryKeyValue any) (T, error)

func (*Builder[T]) First

func (b *Builder[T]) First(tx *sqlx.Tx) (T, error)

func (*Builder[T]) FirstContext

func (b *Builder[T]) FirstContext(ctx context.Context, tx *sqlx.Tx) (T, error)

func (*Builder[T]) From

func (b *Builder[T]) From(table string) *Builder[T]

func (*Builder[T]) Get

func (b *Builder[T]) Get(tx *sqlx.Tx) ([]T, error)

func (*Builder[T]) GetContext

func (b *Builder[T]) GetContext(ctx context.Context, tx *sqlx.Tx) ([]T, error)

func (*Builder[T]) GroupBy

func (b *Builder[T]) GroupBy(columns ...string) *Builder[T]

func (*Builder[T]) Having

func (b *Builder[T]) Having(column, operator string, value any) *Builder[T]

func (*Builder[T]) HavingAnd

func (b *Builder[T]) HavingAnd(cb func(wl *WhereList)) *Builder[T]

func (*Builder[T]) HavingColumn added in v0.4.0

func (b *Builder[T]) HavingColumn(column, operator string, valueColumn string) *Builder[T]

func (*Builder[T]) HavingExists added in v0.4.0

func (b *Builder[T]) HavingExists(query QueryBuilder) *Builder[T]

func (*Builder[T]) HavingHas added in v0.7.0

func (b *Builder[T]) HavingHas(relation string, cb func(q *SubBuilder) *SubBuilder) *Builder[T]

func (*Builder[T]) HavingIn added in v0.4.0

func (b *Builder[T]) HavingIn(column string, values []any) *Builder[T]

func (*Builder[T]) HavingOr

func (b *Builder[T]) HavingOr(cb func(wl *WhereList)) *Builder[T]

func (*Builder[T]) HavingSubquery added in v0.6.0

func (b *Builder[T]) HavingSubquery(subquery QueryBuilder, operator string, value any) *Builder[T]

func (*Builder[T]) Limit

func (b *Builder[T]) Limit(limit int) *Builder[T]

func (*Builder[T]) Load added in v0.3.2

func (b *Builder[T]) Load(tx *sqlx.Tx, v any) error

func (*Builder[T]) LoadContext added in v0.3.2

func (b *Builder[T]) LoadContext(ctx context.Context, tx *sqlx.Tx, v any) error

func (*Builder[T]) LoadOne added in v0.3.2

func (b *Builder[T]) LoadOne(tx *sqlx.Tx, v any) error

func (*Builder[T]) LoadOneContext added in v0.3.2

func (b *Builder[T]) LoadOneContext(ctx context.Context, tx *sqlx.Tx, v any) error

func (*Builder[T]) Offset

func (b *Builder[T]) Offset(offset int) *Builder[T]

func (*Builder[T]) Or

func (b *Builder[T]) Or(cb func(wl *WhereList)) *Builder[T]

func (*Builder[T]) OrHaving

func (b *Builder[T]) OrHaving(column, operator string, value any) *Builder[T]

func (*Builder[T]) OrHavingColumn added in v0.4.0

func (b *Builder[T]) OrHavingColumn(column, operator string, valueColumn string) *Builder[T]

func (*Builder[T]) OrHavingExists added in v0.4.0

func (b *Builder[T]) OrHavingExists(query QueryBuilder) *Builder[T]

func (*Builder[T]) OrHavingHas added in v0.7.0

func (b *Builder[T]) OrHavingHas(relation string, cb func(q *SubBuilder) *SubBuilder) *Builder[T]

func (*Builder[T]) OrHavingIn added in v0.4.0

func (b *Builder[T]) OrHavingIn(column string, values []any) *Builder[T]

func (*Builder[T]) OrHavingSubquery added in v0.6.0

func (b *Builder[T]) OrHavingSubquery(subquery QueryBuilder, operator string, value any) *Builder[T]

func (*Builder[T]) OrWhere

func (b *Builder[T]) OrWhere(column, operator string, value any) *Builder[T]

func (*Builder[T]) OrWhereColumn

func (b *Builder[T]) OrWhereColumn(column, operator string, valueColumn string) *Builder[T]

func (*Builder[T]) OrWhereExists added in v0.4.0

func (b *Builder[T]) OrWhereExists(query QueryBuilder) *Builder[T]

func (*Builder[T]) OrWhereHas added in v0.7.0

func (b *Builder[T]) OrWhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *Builder[T]

func (*Builder[T]) OrWhereIn

func (b *Builder[T]) OrWhereIn(column string, values []any) *Builder[T]

func (*Builder[T]) OrWhereSubquery added in v0.6.0

func (b *Builder[T]) OrWhereSubquery(subquery QueryBuilder, operator string, value any) *Builder[T]

func (*Builder[T]) OrderBy

func (b *Builder[T]) OrderBy(column string) *Builder[T]

func (*Builder[T]) OrderByDesc added in v0.4.2

func (b *Builder[T]) OrderByDesc(column string) *Builder[T]

func (*Builder[T]) Select

func (b *Builder[T]) Select(columns ...string) *Builder[T]

func (*Builder[T]) SelectFunction added in v0.4.0

func (b *Builder[T]) SelectFunction(function, column string) *Builder[T]

func (*Builder[T]) SelectSubquery

func (b *Builder[T]) SelectSubquery(sb QueryBuilder) *Builder[T]

func (*Builder[T]) ToSQL

func (b *Builder[T]) ToSQL(d dialects.Dialect) (string, []any, error)

func (*Builder[T]) Where

func (b *Builder[T]) Where(column, operator string, value any) *Builder[T]

func (*Builder[T]) WhereColumn

func (b *Builder[T]) WhereColumn(column, operator string, valueColumn string) *Builder[T]

func (*Builder[T]) WhereExists added in v0.4.0

func (b *Builder[T]) WhereExists(query QueryBuilder) *Builder[T]

func (*Builder[T]) WhereHas added in v0.7.0

func (b *Builder[T]) WhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *Builder[T]

func (*Builder[T]) WhereIn

func (b *Builder[T]) WhereIn(column string, values []any) *Builder[T]

func (*Builder[T]) WhereSubquery added in v0.6.0

func (b *Builder[T]) WhereSubquery(subquery QueryBuilder, operator string, value any) *Builder[T]

func (*Builder[T]) With added in v0.5.0

func (b *Builder[T]) With(withs ...string) *Builder[T]

type HasMany

type HasMany[T models.Model] struct {
	// contains filtered or unexported fields
}

func (*HasMany[T]) Initialize

func (r *HasMany[T]) Initialize(parent any, field reflect.StructField) error

func (*HasMany[T]) Load

func (r *HasMany[T]) Load(tx *sqlx.Tx, relations []Relationship) error

func (*HasMany) Loaded

func (v *HasMany) Loaded() bool

func (*HasMany) MarshalJSON

func (v *HasMany) MarshalJSON() ([]byte, error)

func (HasMany) Subquery added in v0.7.0

func (r HasMany) Subquery() *SubBuilder

func (*HasMany[T]) Value

func (r *HasMany[T]) Value(tx *sqlx.Tx) ([]T, error)

type HasOne

type HasOne[T models.Model] struct {
	// contains filtered or unexported fields
}

func (*HasOne[T]) Initialize

func (r *HasOne[T]) Initialize(parent any, field reflect.StructField) error

func (*HasOne[T]) Load

func (r *HasOne[T]) Load(tx *sqlx.Tx, relations []Relationship) error

func (*HasOne) Loaded

func (v *HasOne) Loaded() bool

func (*HasOne) MarshalJSON

func (v *HasOne) MarshalJSON() ([]byte, error)

func (HasOne) Subquery added in v0.7.0

func (r HasOne) Subquery() *SubBuilder

func (*HasOne[T]) Value

func (r *HasOne[T]) Value(tx *sqlx.Tx) (T, error)

type Join

type Join struct{}

func (*Join) Join added in v0.7.0

func (j *Join) Join() *Join

type QueryBuilder added in v0.4.1

type QueryBuilder interface {
	builder.ToSQLer
	// contains filtered or unexported methods
}

type Relationship

type Relationship interface {
	Subquery() *SubBuilder
	Initialize(self any, field reflect.StructField) error
	Load(tx *sqlx.Tx, relations []Relationship) error
	Loaded() bool
}

type SubBuilder added in v0.7.0

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

func NewSubBuilder added in v0.7.0

func NewSubBuilder() *SubBuilder

func (*SubBuilder) AddGroupBy added in v0.7.0

func (b *SubBuilder) AddGroupBy(columns ...string) *SubBuilder

func (*SubBuilder) AddSelect added in v0.7.0

func (b *SubBuilder) AddSelect(columns ...string) *SubBuilder

func (*SubBuilder) AddSelectFunction added in v0.7.0

func (b *SubBuilder) AddSelectFunction(function, column string) *SubBuilder

func (*SubBuilder) AddSelectSubquery added in v0.7.0

func (b *SubBuilder) AddSelectSubquery(sb QueryBuilder) *SubBuilder

func (*SubBuilder) And added in v0.7.0

func (b *SubBuilder) And(cb func(wl *WhereList)) *SubBuilder

func (*SubBuilder) Clone added in v0.7.0

func (b *SubBuilder) Clone() *SubBuilder

func (*SubBuilder) Distinct added in v0.7.0

func (b *SubBuilder) Distinct() *SubBuilder

func (*SubBuilder) Dump added in v0.7.0

func (b *SubBuilder) Dump() *SubBuilder

func (*SubBuilder) From added in v0.7.0

func (b *SubBuilder) From(table string) *SubBuilder

func (*SubBuilder) GroupBy added in v0.7.0

func (b *SubBuilder) GroupBy(columns ...string) *SubBuilder

func (*SubBuilder) Having added in v0.7.0

func (b *SubBuilder) Having(column, operator string, value any) *SubBuilder

func (*SubBuilder) HavingAnd added in v0.7.0

func (b *SubBuilder) HavingAnd(cb func(wl *WhereList)) *SubBuilder

func (*SubBuilder) HavingColumn added in v0.7.0

func (b *SubBuilder) HavingColumn(column, operator string, valueColumn string) *SubBuilder

func (*SubBuilder) HavingExists added in v0.7.0

func (b *SubBuilder) HavingExists(query QueryBuilder) *SubBuilder

func (*SubBuilder) HavingHas added in v0.7.0

func (b *SubBuilder) HavingHas(relation string, cb func(q *SubBuilder) *SubBuilder) *SubBuilder

func (*SubBuilder) HavingIn added in v0.7.0

func (b *SubBuilder) HavingIn(column string, values []any) *SubBuilder

func (*SubBuilder) HavingOr added in v0.7.0

func (b *SubBuilder) HavingOr(cb func(wl *WhereList)) *SubBuilder

func (*SubBuilder) HavingSubquery added in v0.7.0

func (b *SubBuilder) HavingSubquery(subquery QueryBuilder, operator string, value any) *SubBuilder

func (*SubBuilder) Limit added in v0.7.0

func (b *SubBuilder) Limit(limit int) *SubBuilder

func (*SubBuilder) Offset added in v0.7.0

func (b *SubBuilder) Offset(offset int) *SubBuilder

func (*SubBuilder) Or added in v0.7.0

func (b *SubBuilder) Or(cb func(wl *WhereList)) *SubBuilder

func (*SubBuilder) OrHaving added in v0.7.0

func (b *SubBuilder) OrHaving(column, operator string, value any) *SubBuilder

func (*SubBuilder) OrHavingColumn added in v0.7.0

func (b *SubBuilder) OrHavingColumn(column, operator string, valueColumn string) *SubBuilder

func (*SubBuilder) OrHavingExists added in v0.7.0

func (b *SubBuilder) OrHavingExists(query QueryBuilder) *SubBuilder

func (*SubBuilder) OrHavingHas added in v0.7.0

func (b *SubBuilder) OrHavingHas(relation string, cb func(q *SubBuilder) *SubBuilder) *SubBuilder

func (*SubBuilder) OrHavingIn added in v0.7.0

func (b *SubBuilder) OrHavingIn(column string, values []any) *SubBuilder

func (*SubBuilder) OrHavingSubquery added in v0.7.0

func (b *SubBuilder) OrHavingSubquery(subquery QueryBuilder, operator string, value any) *SubBuilder

func (*SubBuilder) OrWhere added in v0.7.0

func (b *SubBuilder) OrWhere(column, operator string, value any) *SubBuilder

func (*SubBuilder) OrWhereColumn added in v0.7.0

func (b *SubBuilder) OrWhereColumn(column, operator string, valueColumn string) *SubBuilder

func (*SubBuilder) OrWhereExists added in v0.7.0

func (b *SubBuilder) OrWhereExists(query QueryBuilder) *SubBuilder

func (*SubBuilder) OrWhereHas added in v0.7.0

func (b *SubBuilder) OrWhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *SubBuilder

func (*SubBuilder) OrWhereIn added in v0.7.0

func (b *SubBuilder) OrWhereIn(column string, values []any) *SubBuilder

func (*SubBuilder) OrWhereSubquery added in v0.7.0

func (b *SubBuilder) OrWhereSubquery(subquery QueryBuilder, operator string, value any) *SubBuilder

func (*SubBuilder) OrderBy added in v0.7.0

func (b *SubBuilder) OrderBy(column string) *SubBuilder

func (*SubBuilder) OrderByDesc added in v0.7.0

func (b *SubBuilder) OrderByDesc(column string) *SubBuilder

func (*SubBuilder) Select added in v0.7.0

func (b *SubBuilder) Select(columns ...string) *SubBuilder

func (*SubBuilder) SelectFunction added in v0.7.0

func (b *SubBuilder) SelectFunction(function, column string) *SubBuilder

func (*SubBuilder) SelectSubquery added in v0.7.0

func (b *SubBuilder) SelectSubquery(sb QueryBuilder) *SubBuilder

func (*SubBuilder) ToSQL added in v0.7.0

func (b *SubBuilder) ToSQL(d dialects.Dialect) (string, []any, error)

func (*SubBuilder) Where added in v0.7.0

func (b *SubBuilder) Where(column, operator string, value any) *SubBuilder

func (*SubBuilder) WhereColumn added in v0.7.0

func (b *SubBuilder) WhereColumn(column, operator string, valueColumn string) *SubBuilder

func (*SubBuilder) WhereExists added in v0.7.0

func (b *SubBuilder) WhereExists(query QueryBuilder) *SubBuilder

func (*SubBuilder) WhereHas added in v0.7.0

func (b *SubBuilder) WhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *SubBuilder

func (*SubBuilder) WhereIn added in v0.7.0

func (b *SubBuilder) WhereIn(column string, values []any) *SubBuilder

func (*SubBuilder) WhereSubquery added in v0.7.0

func (b *SubBuilder) WhereSubquery(subquery QueryBuilder, operator string, value any) *SubBuilder

type WhereList

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

func NewWhereList

func NewWhereList() *WhereList

func (*WhereList) And

func (w *WhereList) And(cb func(wl *WhereList)) *WhereList

func (*WhereList) Clone added in v0.3.1

func (w *WhereList) Clone() *WhereList

func (*WhereList) Or

func (w *WhereList) Or(cb func(wl *WhereList)) *WhereList

func (*WhereList) OrWhere

func (w *WhereList) OrWhere(column, operator string, value any) *WhereList

func (*WhereList) OrWhereColumn

func (w *WhereList) OrWhereColumn(column, operator string, valueColumn string) *WhereList

func (*WhereList) OrWhereExists added in v0.4.0

func (w *WhereList) OrWhereExists(query QueryBuilder) *WhereList

func (*WhereList) OrWhereHas added in v0.7.0

func (w *WhereList) OrWhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *WhereList

func (*WhereList) OrWhereIn

func (w *WhereList) OrWhereIn(column string, values []any) *WhereList

func (*WhereList) OrWhereSubquery added in v0.6.0

func (w *WhereList) OrWhereSubquery(subquery QueryBuilder, operator string, value any) *WhereList

func (*WhereList) ToSQL

func (w *WhereList) ToSQL(d dialects.Dialect) (string, []any, error)

func (*WhereList) Where

func (w *WhereList) Where(column, operator string, value any) *WhereList

func (*WhereList) WhereColumn

func (w *WhereList) WhereColumn(column, operator string, valueColumn string) *WhereList

func (*WhereList) WhereExists added in v0.4.0

func (w *WhereList) WhereExists(query QueryBuilder) *WhereList

func (*WhereList) WhereHas added in v0.7.0

func (w *WhereList) WhereHas(relation string, cb func(q *SubBuilder) *SubBuilder) *WhereList

func (*WhereList) WhereIn

func (w *WhereList) WhereIn(column string, values []any) *WhereList

func (*WhereList) WhereSubquery added in v0.6.0

func (w *WhereList) WhereSubquery(subquery QueryBuilder, operator string, value any) *WhereList

Jump to

Keyboard shortcuts

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