Documentation ¶
Overview ¶
Package field provides a way to create field expressions for use with the docstore package.
Index ¶
- func ConvertMods(mods []Mod) docstore.Mods
- type Asc
- type Bool
- func (e Bool) AddFieldPath(path docstore.FieldPath) expr
- func (e Bool) Build() (fieldPath docstore.FieldPath, op string, value interface{})
- func (e Bool) BuildMod() (fieldPath docstore.FieldPath, value interface{})
- func (e Bool) ColumnName() string
- func (field Bool) Eq(value bool) Expr
- func (e Bool) FieldPath() docstore.FieldPath
- func (field Bool) Set(value bool) Mod
- func (e Bool) Unset() Mod
- type Bytes
- func (field Bytes) Eq(value []byte) Expr
- func (field Bytes) Gt(value []byte) Expr
- func (field Bytes) Gte(value []byte) Expr
- func (field Bytes) In(values ...[]byte) Expr
- func (field Bytes) Lt(value []byte) Expr
- func (field Bytes) Lte(value []byte) Expr
- func (field Bytes) NotIn(values ...[]byte) Expr
- func (field Bytes) Set(value []byte) Mod
- type Column
- type Columner
- type Desc
- type DocstoreTag
- type Eq
- type Expr
- type Expression
- type Field
- func (e Field) Asc() OrderByExpression
- func (e Field) BuildOrderBy() (field string, direction string)
- func (e Field) Desc() OrderByExpression
- func (field Field) Eq(value interface{}) Expr
- func (field Field) Gt(value interface{}) Expr
- func (field Field) Gte(value interface{}) Expr
- func (field Field) In(values ...interface{}) Expr
- func (field Field) Lt(value interface{}) Expr
- func (field Field) Lte(value interface{}) Expr
- func (field Field) NotIn(values ...interface{}) Expr
- func (field Field) Set(value interface{}) Mod
- type Float32
- func (field Float32) Eq(value float32) Expr
- func (field Float32) Gt(value float32) Expr
- func (field Float32) Gte(value float32) Expr
- func (field Float32) In(values ...float32) Expr
- func (field Float32) Inc(value float32) Mod
- func (field Float32) Lt(value float32) Expr
- func (field Float32) Lte(value float32) Expr
- func (field Float32) NotIn(values ...float32) Expr
- func (field Float32) Set(value float32) Mod
- type Float64
- func (e Float64) Asc() OrderByExpression
- func (e Float64) BuildOrderBy() (field string, direction string)
- func (e Float64) Desc() OrderByExpression
- func (field Float64) Eq(value float64) Expr
- func (field Float64) Gt(value float64) Expr
- func (field Float64) Gte(value float64) Expr
- func (field Float64) In(values ...float64) Expr
- func (field Float64) Inc(value float64) Mod
- func (field Float64) Lt(value float64) Expr
- func (field Float64) Lte(value float64) Expr
- func (field Float64) NotIn(values ...float64) Expr
- func (field Float64) Set(value float64) Mod
- type Gt
- type Gte
- type In
- type Inc
- type Int
- func (e Int) Asc() OrderByExpression
- func (e Int) BuildOrderBy() (field string, direction string)
- func (e Int) Desc() OrderByExpression
- func (field Int) Eq(value int) Expr
- func (field Int) Gt(value int) Expr
- func (field Int) Gte(value int) Expr
- func (field Int) In(values ...int) Expr
- func (field Int) Inc(value int) Mod
- func (field Int) Lt(value int) Expr
- func (field Int) Lte(value int) Expr
- func (field Int) NotIn(values ...int) Expr
- func (field Int) Set(value int) Mod
- type Int16
- func (field Int16) Eq(value int16) Expr
- func (field Int16) Gt(value int16) Expr
- func (field Int16) Gte(value int16) Expr
- func (field Int16) In(values ...int16) Expr
- func (field Int16) Inc(value int16) Mod
- func (field Int16) Lt(value int16) Expr
- func (field Int16) Lte(value int16) Expr
- func (field Int16) NotIn(values ...int16) Expr
- func (field Int16) Set(value int16) Mod
- type Int32
- func (field Int32) Eq(value int32) Expr
- func (field Int32) Gt(value int32) Expr
- func (field Int32) Gte(value int32) Expr
- func (field Int32) In(values ...int32) Expr
- func (field Int32) Inc(value int32) Mod
- func (field Int32) Lt(value int32) Expr
- func (field Int32) Lte(value int32) Expr
- func (field Int32) NotIn(values ...int32) Expr
- func (field Int32) Set(value int32) Mod
- type Int64
- func (field Int64) Eq(value int64) Expr
- func (field Int64) Gt(value int64) Expr
- func (field Int64) Gte(value int64) Expr
- func (field Int64) In(values ...int64) Expr
- func (field Int64) Inc(value int64) Mod
- func (field Int64) Lt(value int64) Expr
- func (field Int64) Lte(value int64) Expr
- func (field Int64) NotIn(values ...int64) Expr
- func (field Int64) Set(value int64) Mod
- type Int8
- func (field Int8) Eq(value int8) Expr
- func (field Int8) Gt(value int8) Expr
- func (field Int8) Gte(value int8) Expr
- func (field Int8) In(values ...int8) Expr
- func (field Int8) Inc(value int8) Mod
- func (field Int8) Lt(value int8) Expr
- func (field Int8) Lte(value int8) Expr
- func (field Int8) NotIn(values ...int8) Expr
- func (field Int8) Set(value int8) Mod
- type Lt
- type Lte
- type Mod
- type NotIn
- type Option
- type OrderByExpression
- type Set
- type String
- func (e String) Asc() OrderByExpression
- func (e String) BuildOrderBy() (field string, direction string)
- func (e String) Desc() OrderByExpression
- func (field String) Eq(value string) Expr
- func (field String) Gt(value string) Expr
- func (field String) Gte(value string) Expr
- func (field String) In(values ...string) Expr
- func (field String) Lt(value string) Expr
- func (field String) Lte(value string) Expr
- func (field String) NotIn(values ...string) Expr
- func (field String) Set(value string) Mod
- type Tag
- type Time
- func (e Time) Asc() OrderByExpression
- func (e Time) BuildOrderBy() (field string, direction string)
- func (e Time) Desc() OrderByExpression
- func (field Time) Eq(value time.Time) Expr
- func (field Time) Gt(value time.Time) Expr
- func (field Time) Gte(value time.Time) Expr
- func (field Time) In(values ...time.Time) Expr
- func (field Time) Lt(value time.Time) Expr
- func (field Time) Lte(value time.Time) Expr
- func (field Time) NotIn(values ...time.Time) Expr
- func (field Time) Set(value time.Time) Mod
- type Uint
- func (field Uint) Eq(value uint) Expr
- func (field Uint) Gt(value uint) Expr
- func (field Uint) Gte(value uint) Expr
- func (field Uint) In(values ...uint) Expr
- func (field Uint) Inc(value uint) Mod
- func (field Uint) Lt(value uint) Expr
- func (field Uint) Lte(value uint) Expr
- func (field Uint) NotIn(values ...uint) Expr
- func (field Uint) Set(value uint) Mod
- type Uint16
- func (field Uint16) Eq(value uint16) Expr
- func (field Uint16) Gt(value uint16) Expr
- func (field Uint16) Gte(value uint16) Expr
- func (field Uint16) In(values ...uint16) Expr
- func (field Uint16) Inc(value uint16) Mod
- func (field Uint16) Lt(value uint16) Expr
- func (field Uint16) Lte(value uint16) Expr
- func (field Uint16) NotIn(values ...uint16) Expr
- func (field Uint16) Set(value uint16) Mod
- type Uint32
- func (field Uint32) Eq(value uint32) Expr
- func (field Uint32) Gt(value uint32) Expr
- func (field Uint32) Gte(value uint32) Expr
- func (field Uint32) In(values ...uint32) Expr
- func (field Uint32) Inc(value uint32) Mod
- func (field Uint32) Lt(value uint32) Expr
- func (field Uint32) Lte(value uint32) Expr
- func (field Uint32) NotIn(values ...uint32) Expr
- func (field Uint32) Set(value uint32) Mod
- type Uint64
- func (field Uint64) Eq(value uint64) Expr
- func (field Uint64) Gt(value uint64) Expr
- func (field Uint64) Gte(value uint64) Expr
- func (field Uint64) In(values ...uint64) Expr
- func (field Uint64) Inc(value uint64) Mod
- func (field Uint64) Lt(value uint64) Expr
- func (field Uint64) Lte(value uint64) Expr
- func (field Uint64) NotIn(values ...uint64) Expr
- func (field Uint64) Set(value uint64) Mod
- type Uint8
- func (field Uint8) Eq(value uint8) Expr
- func (field Uint8) Gt(value uint8) Expr
- func (field Uint8) Gte(value uint8) Expr
- func (field Uint8) In(values ...uint8) Expr
- func (field Uint8) Inc(value uint8) Mod
- func (field Uint8) Lt(value uint8) Expr
- func (field Uint8) Lte(value uint8) Expr
- func (field Uint8) NotIn(values ...uint8) Expr
- func (field Uint8) Set(value uint8) Mod
- type Unset
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertMods ¶ added in v1.3.0
ConvertMods converts a slice of Mod objects to a docstore.Mods map. It iterates over each Mod in the input slice, calls the BuildMod method to get the field path and value, and adds them to the resulting map. The resulting map is then returned.
Types ¶
type Asc ¶
type Asc struct {
Column Column
}
Asc asc for order by
func (Asc) BuildOrderBy ¶
BuildOrderBy builds the order by clause
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool bool type field
func (Bool) AddFieldPath ¶
AddFieldPath adds a field path to the column.
Example:
field := field.Field{Column: field.Column{Name: "name"}} // "name" field = field.AddFieldPath("user") // "user.name"
func (Bool) Build ¶
Build returns the field path, operator, and value for the expression. If the expression is nil, it returns zero values for all three return types.
func (Bool) BuildMod ¶ added in v1.3.0
BuildMod returns the docstore.FieldPath and value for the modifier.
func (Bool) ColumnName ¶
func (e Bool) ColumnName() string
ColumnName returns the column name (same as the docstore tag name)
func (Bool) FieldPath ¶
FieldPath returns the docstore.FieldPath for the column.
type Bytes ¶
type Bytes String
Bytes []byte type field
type Columner ¶ added in v1.3.0
type Columner interface { // FieldPath returns the field path FieldPath() docstore.FieldPath // ColumnName returns the column name (same as the docstore tag name) ColumnName() string }
Columner column interface
type Desc ¶
type Desc Asc
Desc desc for order by
func (Desc) BuildOrderBy ¶
BuildOrderBy builds the order by clause
type Eq ¶
type Eq struct { Column Column // Column the column to compare Value interface{} // Value the value to compare }
Eq equal to for where
type Expression ¶
type Expression interface { // Build build expression Build() (fieldPath docstore.FieldPath, op string, value interface{}) }
Expression expression interface
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a standard field struct
func NewField ¶
NewField creates a new Field with the specified table, column, and options. It returns a Field struct that represents the field expression.
func (Field) BuildOrderBy ¶
BuildOrderBy returns the field and direction for the order by expression
func (Field) Desc ¶
func (e Field) Desc() OrderByExpression
Desc returns the field in descending order
func (Field) Eq ¶
Eq checks if the field is equal to the provided value
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").Eq("123") fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password = 123
func (Field) Gt ¶
Gt checks if the field is greater than the provided value
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").Gt(123) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password > 123
func (Field) Gte ¶
Gte checks if the field is greater than or equal to the provided value
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").Gte(123) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password >= 123
func (Field) In ¶
In checks if the field is in the provided values
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").In(123, 456, 789) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password in [123 456 789]
func (Field) Lt ¶
Lt checks if the field is less than the provided value
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").Lt(123) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password < 123
func (Field) Lte ¶
Lte checks if the field is less than or equal to the provided value
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").Lte(123) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password <= 123
func (Field) NotIn ¶
NotIn checks if the field is not in the provided values
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewField("user", "password").NotIn(123, 456, 789) fieldPath, op, value := expr.Build() fmt.Println(fieldPath, op, value) }
Output: password not-in [123 456 789]
type Float32 ¶
type Float32 Float64
Float32 float32 type field
func NewFloat32 ¶
NewFloat32 creates a new Float32 field
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 float64 type field
func NewFloat64 ¶
NewFloat64 creates a new Float64 field
func (Float64) Asc ¶
func (e Float64) Asc() OrderByExpression
Asc returns the field in ascending order
func (Float64) BuildOrderBy ¶
BuildOrderBy returns the field and direction for the order by expression
func (Float64) Desc ¶
func (e Float64) Desc() OrderByExpression
Desc returns the field in descending order
type Inc ¶ added in v1.3.0
type Inc[T numeric] struct { Column Column // Column represents the column to increment. Value T // Value represents the value to increment. }
Inc represents an increment operation on a numeric column.
func (Inc[T]) BuildMod ¶ added in v1.3.0
BuildMod returns the field path and value for an increment operation. It constructs a docstore.FieldPath using the column's field path and creates a driver.IncOp with the specified increment amount.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int int type field
func (Int) BuildOrderBy ¶
BuildOrderBy returns the field and direction for the order by expression
type Int16 ¶
type Int16 Int
Int16 int16 type field
type Int32 ¶
type Int32 Int
Int32 int32 type field
type Int64 ¶
type Int64 Int
Int64 int64 type field
type Int8 ¶
type Int8 Int
Int8 int8 type field
type Mod ¶ added in v1.3.0
type Mod interface { // BuildMod build a field path and value for the modifier BuildMod() (fieldPath docstore.FieldPath, value interface{}) }
Mod modifier interface
type OrderByExpression ¶
type OrderByExpression interface { // BuildOrderBy build order by expression BuildOrderBy() (field string, direction string) }
OrderByExpression order by expression interface
type String ¶
type String struct {
// contains filtered or unexported fields
}
String string type field
func (String) Asc ¶
func (e String) Asc() OrderByExpression
Asc returns the field in ascending order
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewString("table", "column").Asc() fieldPath, direction := expr.BuildOrderBy() fmt.Println(fieldPath, direction) }
Output: column asc
func (String) BuildOrderBy ¶
BuildOrderBy returns the field and direction for the order by expression
func (String) Desc ¶
func (e String) Desc() OrderByExpression
Desc returns the field in descending order
Example ¶
package main import ( "fmt" "github.com/bartventer/docstore-gen/field" ) func main() { expr := field.NewString("table", "column").Desc() fieldPath, direction := expr.BuildOrderBy() fmt.Println(fieldPath, direction) }
Output: column desc
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time time type field
func (Time) BuildOrderBy ¶
BuildOrderBy returns the field and direction for the order by expression
func (Time) Desc ¶
func (e Time) Desc() OrderByExpression
Desc returns the field in descending order
type Uint ¶
type Uint Int
Uint uint type field
type Uint16 ¶
type Uint16 Int
Uint16 uint16 type field
type Uint32 ¶
type Uint32 Int
Uint32 uint32 type field
type Uint64 ¶
type Uint64 Int
Uint64 uint64 type field
type Uint8 ¶
type Uint8 Int
Uint8 uint8 type field