Documentation ¶
Index ¶
- func InitializeRelationships(v any) error
- func Load(tx *sqlx.Tx, v any, relation string) error
- func NewSelects() *selects
- type AfterLoader
- type AfterSaver
- type BeforeSaver
- type BelongsTo
- type Builder
- func (b *Builder[T]) AddGroupBy(columns ...string) *Builder[T]
- func (b *Builder[T]) AddOrderBy(columns ...string) *Builder[T]
- func (b *Builder[T]) AddSelect(columns ...string) *Builder[T]
- func (b *Builder[T]) AddSelectSubquery(sb *Builder[T]) *Builder[T]
- func (b *Builder[T]) And(cb func(b *WhereList)) *Builder[T]
- func (b *Builder[T]) Distinct() *Builder[T]
- func (b *Builder[T]) Dump() *Builder[T]
- func (b *Builder[T]) Find(tx *sqlx.Tx, primaryKeyValues ...any) (T, error)
- func (b *Builder[T]) FindContext(ctx context.Context, tx *sqlx.Tx, primaryKeyValues ...any) (T, error)
- func (b *Builder[T]) First(tx *sqlx.Tx) (T, error)
- func (b *Builder[T]) FirstContext(ctx context.Context, tx *sqlx.Tx) (T, error)
- func (b *Builder[T]) From(table string) *Builder[T]
- func (b *Builder[T]) Get(tx *sqlx.Tx) ([]T, error)
- func (b *Builder[T]) GetContext(ctx context.Context, tx *sqlx.Tx) ([]T, error)
- func (b *Builder[T]) GroupBy(columns ...string) *Builder[T]
- func (b *Builder[T]) Having(column, operator string, value any) *Builder[T]
- func (b *Builder[T]) HavingAnd(cb func(b *WhereList)) *Builder[T]
- func (b *Builder[T]) HavingOr(cb func(b *WhereList)) *Builder[T]
- func (b *Builder[T]) Join() *Builder[T]
- func (b *Builder[T]) Limit(limit int) *Builder[T]
- func (b *Builder[T]) Offset(offset int) *Builder[T]
- func (b *Builder[T]) Or(cb func(b *WhereList)) *Builder[T]
- func (b *Builder[T]) OrHaving(column, operator string, value any) *Builder[T]
- func (b *Builder[T]) OrWhere(column, operator string, value any) *Builder[T]
- func (b *Builder[T]) OrWhereColumn(column, operator string, valueColumn string) *Builder[T]
- func (b *Builder[T]) OrWhereIn(column string, values []any) *Builder[T]
- func (b *Builder[T]) OrderBy(columns ...string) *Builder[T]
- func (b *Builder[T]) Select(columns ...string) *Builder[T]
- func (b *Builder[T]) SelectSubquery(sb *Builder[T]) *Builder[T]
- func (b *Builder[T]) ToSQL(d dialects.Dialect) (string, []any, error)
- func (b *Builder[T]) Where(column, operator string, value any) *Builder[T]
- func (b *Builder[T]) WhereColumn(column, operator string, valueColumn string) *Builder[T]
- func (b *Builder[T]) WhereIn(column string, values []any) *Builder[T]
- type HasMany
- type HasOne
- type Join
- type Relationship
- type WhereList
- func (w *WhereList) And(cb func(w *WhereList)) *WhereList
- func (w *WhereList) Or(cb func(w *WhereList)) *WhereList
- func (w *WhereList) OrWhere(column, operator string, value any) *WhereList
- func (w *WhereList) OrWhereColumn(column, operator string, valueColumn string) *WhereList
- func (w *WhereList) OrWhereIn(column string, values []any) *WhereList
- func (w *WhereList) ToSQL(d dialects.Dialect) (string, []any, error)
- func (w *WhereList) Where(column, operator string, value any) *WhereList
- func (w *WhereList) WhereColumn(column, operator string, valueColumn string) *WhereList
- func (w *WhereList) WhereIn(column string, values []any) *WhereList
- type Wheres
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeRelationships ¶
func NewSelects ¶
func NewSelects() *selects
Types ¶
type BeforeSaver ¶
type BelongsTo ¶
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) MarshalJSON ¶
type Builder ¶
func (*Builder[T]) AddGroupBy ¶
func (*Builder[T]) AddOrderBy ¶
func (*Builder[T]) AddSelectSubquery ¶
func (*Builder[T]) FindContext ¶
func (*Builder[T]) FirstContext ¶
func (*Builder[T]) GetContext ¶
func (*Builder[T]) OrWhereColumn ¶
func (*Builder[T]) SelectSubquery ¶
func (*Builder[T]) WhereColumn ¶
type HasMany ¶
func (*HasMany[T]) Initialize ¶
func (r *HasMany[T]) Initialize(parent any, field reflect.StructField) error
func (*HasMany) MarshalJSON ¶
type HasOne ¶
func (*HasOne[T]) Initialize ¶
func (r *HasOne[T]) Initialize(parent any, field reflect.StructField) error
func (*HasOne[T]) Loaded ¶
func (r *HasOne[T]) Query() *selects.Builder { var related T local, ok := builder.GetValue(r.parent, r.localKey) if !ok { panic(fmt.Errorf("no local key %s", r.localKey)) } return selects.New(). Select("*"). From(builder.GetTable(related)). Where(r.foreignKey, "=", local). Limit(1) }
func (*HasOne) MarshalJSON ¶
type Relationship ¶
type Relationship interface { // Query() *selects.Builder Initialize(self any, field reflect.StructField) error Load(tx *sqlx.Tx, relations []Relationship) error Loaded() bool }
type WhereList ¶
type WhereList struct {
// contains filtered or unexported fields
}
func NewWhereList ¶
func NewWhereList() *WhereList
func (*WhereList) OrWhereColumn ¶
func (*WhereList) WhereColumn ¶
Click to show internal directories.
Click to hide internal directories.