Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applier ¶
type Applier interface {
ApplyWhere(clause string, args []any)
ApplyOrderBy(clause string)
ApplyLimit(n int)
ApplyOffset(n int)
ApplySelect(columns string)
}
Applier is implemented by query builders to receive scope fragments. This interface lives in the scope package so that orm can import scope without creating circular dependencies.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope represents a single query condition fragment. Scopes are immutable and safe to reuse across queries.
func In ¶
In returns a WHERE scope with an IN clause, expanding the slice into individual placeholders. No reflection is used; generics handle the type conversion.
scope.In("id", []int{1, 2, 3}) // → WHERE id IN (?, ?, ?)
func OrderBy ¶
OrderBy returns a Scope that sets the ORDER BY clause.
scope.OrderBy("created_at DESC")
func Select ¶
Select returns a Scope that overrides the SELECT column list.
scope.Select("id", "name")
type Scopes ¶
type Scopes []Scope
Scopes is a named slice of Scope, useful for conditionally building up a set of scopes.
var s scope.Scopes
if onlyActive {
s = s.Append(Active)
}
s = s.Append(Paginate(page, perPage))
Users(db).Scopes(s...).All(ctx)
func Combine ¶
Combine creates a Scopes from the given scopes.
scope.Combine(scope.Limit(10), scope.Offset(20))