Documentation
¶
Index ¶
- Variables
- func ApplyWhereCondition[T model.Model](condition WhereCondition[T], query *CQLQuery, table Table) error
- func Select[TResults any](query IQuery, selections []Selection[TResults]) ([]TResults, error)
- type Aggregation
- type AggregationCondition
- type AggregationResult
- func (aggregation AggregationResult[T]) Eq(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) GetValue() T
- func (aggregation AggregationResult[T]) Gt(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) GtOrEq(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) In(values []T) AggregationCondition
- func (aggregation AggregationResult[T]) Like(value string) AggregationCondition
- func (aggregation AggregationResult[T]) Lt(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) LtOrEq(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) NotEq(value ValueOfType[T]) AggregationCondition
- func (aggregation AggregationResult[T]) NotIn(values []T) AggregationCondition
- func (aggregation AggregationResult[T]) ToSQL(query *CQLQuery) (string, []any, error)
- type BoolField
- type BoolFieldAggregation
- type BoolFieldIs
- func (is BoolFieldIs[TObject]) False() WhereCondition[TObject]
- func (is BoolFieldIs[TObject]) NotFalse() WhereCondition[TObject]
- func (is BoolFieldIs[TObject]) NotTrue() WhereCondition[TObject]
- func (is BoolFieldIs[TObject]) NotUnknown() WhereCondition[TObject]
- func (is BoolFieldIs[TObject]) True() WhereCondition[TObject]
- func (is BoolFieldIs[TObject]) Unknown() WhereCondition[TObject]
- type BoolValue
- type CQLQuery
- func (query *CQLQuery) AddConcernedModel(model model.Model, table Table)
- func (query *CQLQuery) AddSelect(sql string)
- func (query *CQLQuery) AddSelectField(table Table, fieldID IField, addAs bool)
- func (query CQLQuery) ColumnName(table Table, fieldName string) string
- func (query *CQLQuery) Count() (int64, error)
- func (query *CQLQuery) Delete(cqlSubQuery *CQLQuery) (int64, error)
- func (query CQLQuery) Dialector() sql.Dialector
- func (query *CQLQuery) Find(dest any) error
- func (query *CQLQuery) First(dest any) error
- func (query *CQLQuery) GetModelTable(field IField) (Table, error)
- func (query *CQLQuery) GetTables(modelType reflect.Type) []Table
- func (query *CQLQuery) GroupBy(fields []IField) error
- func (query *CQLQuery) Having(sql string, args ...any)
- func (query *CQLQuery) Joins(joinQuery string, isLeftJoin bool, args ...interface{})
- func (query *CQLQuery) Last(dest any) error
- func (query *CQLQuery) Limit(limit int)
- func (query *CQLQuery) Offset(offset int)
- func (query *CQLQuery) Order(field IField, descending bool) error
- func (query *CQLQuery) Preload(preloadQuery string, args ...interface{})
- func (query *CQLQuery) Returning(dest any) error
- func (query *CQLQuery) SoftDelete(softDeleteColumnName string) (int64, error)
- func (query *CQLQuery) Take(dest any) error
- func (query *CQLQuery) Unscoped()
- func (query *CQLQuery) Update(sets []ISet) (int64, error)
- func (query *CQLQuery) Where(whereQuery interface{}, args ...interface{})
- type Collection
- func (collection Collection[TObject, TAttribute]) All(firstCondition WhereCondition[TAttribute], ...) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) Any(firstCondition WhereCondition[TAttribute], ...) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) None(firstCondition WhereCondition[TAttribute], ...) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) Preload(nestedPreloads ...JoinCondition[TAttribute]) Condition[TObject]
- type Condition
- type Delete
- type Field
- func (field Field[TModel, TAttribute]) Aggregate() FieldAggregation[TAttribute]
- func (field Field[TModel, TAttribute]) Appearance(number uint) Field[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) GetValue() TAttribute
- func (field Field[TModel, TAttribute]) Is() FieldIs[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) IsUnsafe() UnsafeFieldIs[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) ToSQL(query *CQLQuery) (string, []any, error)
- func (field Field[TModel, TAttribute]) ToSQLForTable(query *CQLQuery, table Table) (string, []any, error)
- type FieldAggregation
- type FieldIs
- func (is FieldIs[TObject, TAttribute]) Between(v1, v2 ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Custom(op Operator[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Distinct(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Eq(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Gt(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) In(values ...ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Lt(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotBetween(v1, v2 ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotIn(values ...ValueOfType[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotNull() WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Null() WhereCondition[TObject]
- type FieldOfModel
- type FieldSet
- type IField
- type IQuery
- type ISet
- type IValue
- type IValueList
- type Insert
- func (insert *Insert[T]) Exec() (int64, error)
- func (insert *Insert[T]) ExecInBatches(batchSize int) (int64, error)
- func (insert *Insert[T]) OnConflict() *InsertOnConflict[T]
- func (insert *Insert[T]) OnConflictOn(field FieldOfModel[T], fields ...FieldOfModel[T]) *InsertOnConflict[T]
- func (insert *Insert[T]) OnConstraint(constraintName string) *InsertOnConflict[T]
- type InsertExec
- type InsertOnConflict
- func (insertOnConflict *InsertOnConflict[T]) DoNothing() *InsertExec[T]
- func (insertOnConflict *InsertOnConflict[T]) Set(sets ...*Set[T]) *InsertOnConflictSet[T]
- func (insertOnConflict *InsertOnConflict[T]) Update(fields ...FieldOfModel[T]) *InsertExec[T]
- func (insertOnConflict *InsertOnConflict[T]) UpdateAll() *InsertExec[T]
- type InsertOnConflictSet
- type JoinCondition
- type LikeOperator
- type NotUpdatableNumericField
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Absolute() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Aggregate() NumericFieldAggregation
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) And(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Divided(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) GetNumericValue() TAttribute
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) GetValue() float64
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Is() NumericFieldIs[TModel]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Minus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Modulo(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Not() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Or(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Plus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Power(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) ShiftLeft(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) ShiftRight(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) SquareRoot() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Times(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NotUpdatableNumericField[TModel, TAttribute]) Xor(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- type NotUpdatableStringField
- type NullableBoolField
- type NullableField
- type NullableFieldSet
- type NullableNumericField
- type NullableNumericFieldSet
- type NullableStringField
- type Numeric
- type NumericField
- func (numericField NumericField[TModel, TAttribute]) Absolute() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Aggregate() NumericFieldAggregation
- func (numericField NumericField[TModel, TAttribute]) And(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Appearance(number uint) NumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Divided(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) GetNumericValue() TAttribute
- func (numericField NumericField[TModel, TAttribute]) GetValue() float64
- func (numericField NumericField[TModel, TAttribute]) Is() NumericFieldIs[TModel]
- func (numericField NumericField[TModel, TAttribute]) Minus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Modulo(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Not() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Or(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Plus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Power(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Set() NumericFieldSet[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) ShiftLeft(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) ShiftRight(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) SquareRoot() NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Times(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Xor(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
- type NumericFieldAggregation
- func (fieldAggregation NumericFieldAggregation) And() AggregationResult[float64]
- func (fieldAggregation NumericFieldAggregation) Average() AggregationResult[float64]
- func (fieldAggregation NumericFieldAggregation) Max() AggregationResult[float64]
- func (fieldAggregation NumericFieldAggregation) Min() AggregationResult[float64]
- func (fieldAggregation NumericFieldAggregation) Or() AggregationResult[float64]
- func (fieldAggregation NumericFieldAggregation) Sum() AggregationResult[float64]
- type NumericFieldIs
- type NumericFieldSet
- type NumericOfType
- type NumericValue
- func Float32(value float32) NumericValue[float32]
- func Float64(value float64) NumericValue[float64]
- func Int(value int) NumericValue[int]
- func Int16(value int16) NumericValue[int16]
- func Int32(value int32) NumericValue[int32]
- func Int64(value int64) NumericValue[int64]
- func Int8(value int8) NumericValue[int8]
- func UInt(value uint) NumericValue[uint]
- func UInt16(value uint16) NumericValue[uint16]
- func UInt32(value uint32) NumericValue[uint32]
- func UInt64(value uint64) NumericValue[uint64]
- func UInt8(value uint8) NumericValue[uint8]
- func UIntPTR(value uintptr) NumericValue[uintptr]
- type Operator
- func Between[T any](v1, v2 IValue) Operator[T]
- func Eq[T any](value IValue) Operator[T]
- func Gt[T any](value IValue) Operator[T]
- func GtOrEq[T any](value IValue) Operator[T]
- func In[T any](values IValueList[T]) Operator[T]
- func IsDistinct[T any](value IValue) Operator[T]
- func IsNotDistinct[T any](value IValue) Operator[T]
- func IsNotNull[T any]() Operator[T]
- func IsNull[T any]() Operator[T]
- func Lt[T any](value IValue) Operator[T]
- func LtOrEq[T any](value IValue) Operator[T]
- func NotBetween[T any](v1, v2 IValue) Operator[T]
- func NotEq[T any](value IValue) Operator[T]
- func NotIn[T any](values IValueList[T]) Operator[T]
- type OrderLimitReturning
- type PredicateOperator
- type Query
- func (query *Query[T]) Ascending(field IField) *Query[T]
- func (query *Query[T]) Count() (int64, error)
- func (query *Query[T]) Descending(field IField) *Query[T]
- func (query *Query[T]) Find() ([]*T, error)
- func (query *Query[T]) FindOne() (*T, error)
- func (query *Query[T]) First() (*T, error)
- func (query *Query[T]) GroupBy(fields ...IField) *QueryGroup
- func (query *Query[T]) Last() (*T, error)
- func (query *Query[T]) Limit(limit int) *Query[T]
- func (query *Query[T]) Offset(offset int) *Query[T]
- func (query *Query[T]) Take() (*T, error)
- type QueryGroup
- type Selection
- type Set
- type StringField
- type StringFieldIs
- type Table
- type UnsafeCondition
- type UnsafeFieldIs
- func (is UnsafeFieldIs[TObject, TAttribute]) Between(v1, v2 IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Distinct(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Eq(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Gt(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) GtOrEq(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Lt(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) LtOrEq(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotBetween(v1, v2 IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotDistinct(value IValue) WhereCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotEq(value IValue) WhereCondition[TObject]
- type UpdatableField
- type Update
- func (update *Update[T]) Ascending(field IField) *Update[T]
- func (update *Update[T]) Descending(field IField) *Update[T]
- func (update *Update[T]) Limit(limit int) *Update[T]
- func (update *Update[T]) Returning(dest *[]T) *Update[T]
- func (update *Update[T]) Set(sets ...*Set[T]) (int64, error)
- func (update *Update[T]) SetMultiple(sets ...ISet) (int64, error)
- type Value
- type ValueOfType
- type ValueOperator
- type WhereCondition
- func And[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
- func NewConnectionCondition[T model.Model](connector sql.Operator, conditions []WhereCondition[T]) WhereCondition[T]
- func NewContainerCondition[T model.Model](prefix sql.Operator, conditions []WhereCondition[T]) WhereCondition[T]
- func NewFieldCondition[TObject model.Model, TAttribute any](fieldIdentifier IField, operator Operator[TAttribute]) WhereCondition[TObject]
- func Not[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
- func Or[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
Constants ¶
This section is empty.
Variables ¶
var ( ErrFieldModelNotConcerned = errors.New("field's model is not concerned by the query (not joined)") ErrAppearanceMustBeSelected = errors.New("field's model appears more than once, select which one you want to use with Appearance") ErrAppearanceOutOfRange = errors.New("selected appearance is bigger than field's model number of appearances") ErrEmptyConditions = errors.New("at least one condition is required") ErrMoreThanOneObjectFound = errors.New("found more that one object that meet the requested conditions") ErrObjectNotFound = errors.New("no object exists that meets the requested conditions") ErrUnsupportedByDatabase = errors.New("method not supported by database") ErrOrderByMustBeCalled = errors.New("order by must be called before limit in an update statement") ErrOnlyPreloadsAllowed = errors.New("only conditions that do a preload are allowed") ErrPreloadsInDeleteReturningNotAllowed = errors.New("preloads in delete returning are not allowed") )
Functions ¶
func ApplyWhereCondition ¶
func ApplyWhereCondition[T model.Model](condition WhereCondition[T], query *CQLQuery, table Table) error
apply WhereCondition of any type on the query
Types ¶
type Aggregation ¶ added in v0.1.3
type AggregationCondition ¶ added in v0.1.3
type AggregationCondition struct {
// contains filtered or unexported fields
}
func ConnectionAggregationCondition ¶ added in v0.1.3
func ConnectionAggregationCondition(conditions []AggregationCondition, operator sql.Operator) AggregationCondition
func ContainerAggregationCondition ¶ added in v0.1.3
func ContainerAggregationCondition(conditions []AggregationCondition, operator sql.Operator) AggregationCondition
type AggregationResult ¶ added in v0.1.3
type AggregationResult[T any] struct { Function sql.FunctionByDialector // contains filtered or unexported fields }
func (AggregationResult[T]) Eq ¶ added in v0.1.3
func (aggregation AggregationResult[T]) Eq(value ValueOfType[T]) AggregationCondition
EqualTo
func (AggregationResult[T]) GetValue ¶ added in v0.2.0
func (aggregation AggregationResult[T]) GetValue() T
func (AggregationResult[T]) Gt ¶ added in v0.1.3
func (aggregation AggregationResult[T]) Gt(value ValueOfType[T]) AggregationCondition
GreaterThan
func (AggregationResult[T]) GtOrEq ¶ added in v0.1.3
func (aggregation AggregationResult[T]) GtOrEq(value ValueOfType[T]) AggregationCondition
GreaterThanOrEqualTo
func (AggregationResult[T]) In ¶ added in v0.1.3
func (aggregation AggregationResult[T]) In(values []T) AggregationCondition
func (AggregationResult[T]) Like ¶ added in v0.1.3
func (aggregation AggregationResult[T]) Like(value string) AggregationCondition
Pattern in all databases:
- An underscore (_) in pattern stands for (matches) any single character.
- A percent sign (%) matches any sequence of zero or more characters.
Additionally in SQLServer:
- Square brackets ([ ]) matches any single character within the specified range ([a-f]) or set ([abcdef]).
- [^] matches any single character not within the specified range ([^a-f]) or set ([^abcdef]).
WARNINGS:
- SQLite: LIKE is case-insensitive unless case_sensitive_like pragma (https://www.sqlite.org/pragma.html#pragma_case_sensitive_like) is true.
- SQLServer, MySQL: the case-sensitivity depends on the collation used in compared column.
- PostgreSQL: LIKE is always case-sensitive
refs:
- mysql: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like
- postgresql: https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
- sqlserver: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver16
- sqlite: https://www.sqlite.org/lang_expr.html#like
func (AggregationResult[T]) Lt ¶ added in v0.1.3
func (aggregation AggregationResult[T]) Lt(value ValueOfType[T]) AggregationCondition
LessThan
func (AggregationResult[T]) LtOrEq ¶ added in v0.1.3
func (aggregation AggregationResult[T]) LtOrEq(value ValueOfType[T]) AggregationCondition
LessThanOrEqualTo
func (AggregationResult[T]) NotEq ¶ added in v0.1.3
func (aggregation AggregationResult[T]) NotEq(value ValueOfType[T]) AggregationCondition
NotEqualTo
func (AggregationResult[T]) NotIn ¶ added in v0.1.3
func (aggregation AggregationResult[T]) NotIn(values []T) AggregationCondition
type BoolField ¶
type BoolField[TModel model.Model] struct { UpdatableField[TModel, bool] }
func NewBoolField ¶ added in v0.0.8
func (BoolField[TModel]) Aggregate ¶ added in v0.1.3
func (boolField BoolField[TModel]) Aggregate() BoolFieldAggregation
Aggregate allows applying aggregation functions to the field inside a group by
func (BoolField[TModel]) Appearance ¶ added in v0.2.1
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (BoolField[TModel]) Is ¶
func (boolField BoolField[TModel]) Is() BoolFieldIs[TModel]
type BoolFieldAggregation ¶ added in v0.1.3
type BoolFieldAggregation struct {
FieldAggregation[bool]
}
func (BoolFieldAggregation) All ¶ added in v0.1.3
func (fieldAggregation BoolFieldAggregation) All() AggregationResult[bool]
All returns true if all the values are true
func (BoolFieldAggregation) Any ¶ added in v0.1.3
func (fieldAggregation BoolFieldAggregation) Any() AggregationResult[bool]
All returns true if at least one value is true
func (BoolFieldAggregation) None ¶ added in v0.1.3
func (fieldAggregation BoolFieldAggregation) None() AggregationResult[bool]
None returns true if all values are false
type BoolFieldIs ¶
func (BoolFieldIs[TObject]) False ¶
func (is BoolFieldIs[TObject]) False() WhereCondition[TObject]
func (BoolFieldIs[TObject]) NotFalse ¶
func (is BoolFieldIs[TObject]) NotFalse() WhereCondition[TObject]
func (BoolFieldIs[TObject]) NotTrue ¶
func (is BoolFieldIs[TObject]) NotTrue() WhereCondition[TObject]
func (BoolFieldIs[TObject]) NotUnknown ¶
func (is BoolFieldIs[TObject]) NotUnknown() WhereCondition[TObject]
func (BoolFieldIs[TObject]) True ¶
func (is BoolFieldIs[TObject]) True() WhereCondition[TObject]
func (BoolFieldIs[TObject]) Unknown ¶
func (is BoolFieldIs[TObject]) Unknown() WhereCondition[TObject]
type CQLQuery ¶ added in v0.2.0
type CQLQuery struct {
// contains filtered or unexported fields
}
func ApplyConditions ¶
Create a GormQuery to which the conditions are applied
func NewGormQuery ¶
func (*CQLQuery) AddConcernedModel ¶ added in v0.2.0
func (*CQLQuery) AddSelect ¶ added in v0.2.0
Select specify fields that you want when querying, creating, updating
func (*CQLQuery) AddSelectField ¶ added in v0.2.0
func (CQLQuery) ColumnName ¶ added in v0.2.0
func (*CQLQuery) Count ¶ added in v0.2.0
Count returns the amount of models that fulfill the conditions
func (*CQLQuery) First ¶ added in v0.2.0
First finds the first record ordered by primary key, matching given conditions
func (*CQLQuery) GetModelTable ¶ added in v0.2.0
func (*CQLQuery) Having ¶ added in v0.2.0
Having allows filter groups of rows based on conditions involving aggregate functions
func (*CQLQuery) Last ¶ added in v0.2.0
Last finds the last record ordered by primary key, matching given conditions
func (*CQLQuery) Limit ¶ added in v0.2.0
Limit specify the number of records to be retrieved
Limit conditions can be cancelled by using `Limit(-1)`
func (*CQLQuery) Offset ¶ added in v0.2.0
Offset specify the number of records to skip before starting to return the records
Offset conditions can be cancelled by using `Offset(-1)`.
func (*CQLQuery) Order ¶ added in v0.2.0
Order specify order when retrieving models from database.
if descending is true, the ordering is in descending direction.
func (*CQLQuery) Returning ¶ added in v0.2.0
available for: postgres, sqlite, sqlserver
warning: in sqlite, sqlserver preloads are not allowed
func (*CQLQuery) SoftDelete ¶ added in v0.6.0
func (*CQLQuery) Take ¶ added in v0.2.0
Take finds the first record returned by the database in no specified order, matching given conditions
type Collection ¶ added in v0.0.6
type Collection[TObject model.Model, TAttribute model.Model] struct { // contains filtered or unexported fields }
func NewCollection ¶ added in v0.0.6
func (Collection[TObject, TAttribute]) All ¶ added in v0.0.6
func (collection Collection[TObject, TAttribute]) All( firstCondition WhereCondition[TAttribute], conditions ...WhereCondition[TAttribute], ) WhereCondition[TObject]
All generates a condition that is true if all models in the collection fulfill the conditions (or is empty)
func (Collection[TObject, TAttribute]) Any ¶ added in v0.0.6
func (collection Collection[TObject, TAttribute]) Any( firstCondition WhereCondition[TAttribute], conditions ...WhereCondition[TAttribute], ) WhereCondition[TObject]
Any generates a condition that is true if at least one model in the collection fulfills the conditions
func (Collection[TObject, TAttribute]) None ¶ added in v0.0.6
func (collection Collection[TObject, TAttribute]) None( firstCondition WhereCondition[TAttribute], conditions ...WhereCondition[TAttribute], ) WhereCondition[TObject]
None generates a condition that is true if no model in the collection fulfills the conditions
func (Collection[TObject, TAttribute]) Preload ¶ added in v0.0.6
func (collection Collection[TObject, TAttribute]) Preload(nestedPreloads ...JoinCondition[TAttribute]) Condition[TObject]
Preload collection of models
nestedPreloads can be used to preload relations of the models inside the collection
type Condition ¶
func NewCollectionPreloadCondition ¶
func NewCollectionPreloadCondition[T1, T2 model.Model]( collectionField string, nestedPreloads []JoinCondition[T2], ) Condition[T1]
Condition used to the preload a collection of models of a model
type Delete ¶
type Delete[T model.Model] struct { OrderLimitReturning[T] // contains filtered or unexported fields }
func (*Delete[T]) Ascending ¶
Ascending specify an ascending order when updating models
available for: mysql
func (*Delete[T]) Descending ¶
Descending specify a descending order when updating models
available for: mysql
type Field ¶
func (Field[TModel, TAttribute]) Aggregate ¶ added in v0.1.3
func (field Field[TModel, TAttribute]) Aggregate() FieldAggregation[TAttribute]
Aggregate allows applying aggregation functions to the field inside a group by
func (Field[TModel, TAttribute]) Appearance ¶ added in v0.1.2
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (Field[TModel, TAttribute]) GetValue ¶ added in v0.2.1
func (field Field[TModel, TAttribute]) GetValue() TAttribute
func (Field[TModel, TAttribute]) Is ¶
Is allows creating conditions that include the field and a static value
func (Field[TModel, TAttribute]) IsUnsafe ¶ added in v0.0.10
func (field Field[TModel, TAttribute]) IsUnsafe() UnsafeFieldIs[TModel, TAttribute]
Should not be used.
IsUnsafe allows creating conditions that include the field and are not verified in compilation time.
type FieldAggregation ¶ added in v0.1.3
type FieldAggregation[T any] struct { // contains filtered or unexported fields }
func (FieldAggregation[T]) Count ¶ added in v0.1.3
func (fieldAggregation FieldAggregation[T]) Count() AggregationResult[float64]
Count returns the number of values that are not null
func (FieldAggregation[T]) Max ¶ added in v0.1.3
func (fieldAggregation FieldAggregation[T]) Max() AggregationResult[T]
Max returns the maximum value of all values
func (FieldAggregation[T]) Min ¶ added in v0.1.3
func (fieldAggregation FieldAggregation[T]) Min() AggregationResult[T]
Min returns the minimum value of all values
type FieldIs ¶
type FieldIs[TObject model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (FieldIs[TObject, TAttribute]) Between ¶
func (is FieldIs[TObject, TAttribute]) Between(v1, v2 ValueOfType[TAttribute]) WhereCondition[TObject]
Equivalent to v1 < value < v2
func (FieldIs[TObject, TAttribute]) Custom ¶
func (is FieldIs[TObject, TAttribute]) Custom(op Operator[TAttribute]) WhereCondition[TObject]
Custom can be used to use other Operators, like database specific operators
func (FieldIs[TObject, TAttribute]) Distinct ¶
func (is FieldIs[TObject, TAttribute]) Distinct(value ValueOfType[TAttribute]) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) Eq ¶
func (is FieldIs[TObject, TAttribute]) Eq(value ValueOfType[TAttribute]) WhereCondition[TObject]
EqualTo NotDistinct must be used in cases where value can be NULL
func (FieldIs[TObject, TAttribute]) Gt ¶
func (is FieldIs[TObject, TAttribute]) Gt(value ValueOfType[TAttribute]) WhereCondition[TObject]
GreaterThan
func (FieldIs[TObject, TAttribute]) GtOrEq ¶
func (is FieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
GreaterThanOrEqualTo
func (FieldIs[TObject, TAttribute]) In ¶
func (is FieldIs[TObject, TAttribute]) In(values ...ValueOfType[TAttribute]) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) Lt ¶
func (is FieldIs[TObject, TAttribute]) Lt(value ValueOfType[TAttribute]) WhereCondition[TObject]
LessThan
func (FieldIs[TObject, TAttribute]) LtOrEq ¶
func (is FieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
LessThanOrEqualTo
func (FieldIs[TObject, TAttribute]) NotBetween ¶
func (is FieldIs[TObject, TAttribute]) NotBetween(v1, v2 ValueOfType[TAttribute]) WhereCondition[TObject]
Equivalent to NOT (v1 < value < v2)
func (FieldIs[TObject, TAttribute]) NotDistinct ¶
func (is FieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[TAttribute]) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) NotEq ¶
func (is FieldIs[TObject, TAttribute]) NotEq(value ValueOfType[TAttribute]) WhereCondition[TObject]
NotEqualTo Distinct must be used in cases where value can be NULL
func (FieldIs[TObject, TAttribute]) NotIn ¶
func (is FieldIs[TObject, TAttribute]) NotIn(values ...ValueOfType[TAttribute]) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) NotNull ¶
func (is FieldIs[TObject, TAttribute]) NotNull() WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) Null ¶
func (is FieldIs[TObject, TAttribute]) Null() WhereCondition[TObject]
type FieldOfModel ¶ added in v0.4.0
type FieldSet ¶
type FieldSet[TModel model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (FieldSet[TModel, TAttribute]) Eq ¶
func (set FieldSet[TModel, TAttribute]) Eq(value ValueOfType[TAttribute]) *Set[TModel]
type IValueList ¶ added in v0.2.0
type IValueList[T any] []ValueOfType[T]
type Insert ¶ added in v0.4.0
func (*Insert[T]) Exec ¶ added in v0.4.0
Exec execute the insert statement, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
func (*Insert[T]) ExecInBatches ¶ added in v0.4.0
ExecInBatches execute the insert statement in batches of batchSize, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
func (*Insert[T]) OnConflict ¶ added in v0.4.0
func (insert *Insert[T]) OnConflict() *InsertOnConflict[T]
OnConflict allows to set the action to be taken when any conflict happens when inserting the data.
WARNING: in postgres OnConflict can be used only with DoNothing, for UpdateAll, Update and Set, OnConflictOn must be used
func (*Insert[T]) OnConflictOn ¶ added in v0.4.0
func (insert *Insert[T]) OnConflictOn(field FieldOfModel[T], fields ...FieldOfModel[T]) *InsertOnConflict[T]
OnConflictOn allows to set the action to be taken when a conflict with the fields specified by parameter happens when inserting the data. For this, there must be a constraint on these fields, otherwise an error will be returned.
Available for: postgres, sqlite
func (*Insert[T]) OnConstraint ¶ added in v0.4.0
func (insert *Insert[T]) OnConstraint(constraintName string) *InsertOnConflict[T]
OnConstraint allows to set the action to be taken when a conflict with the constraint specified by parameter happens when inserting the data. For this, the constraint must exist, otherwise an error will be returned.
Available for: postgres
type InsertExec ¶ added in v0.4.0
func (*InsertExec[T]) Exec ¶ added in v0.4.0
func (insertExec *InsertExec[T]) Exec() (int64, error)
Exec execute the insert statement, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
func (*InsertExec[T]) ExecInBatches ¶ added in v0.4.0
func (insertExec *InsertExec[T]) ExecInBatches(batchSize int) (int64, error)
ExecInBatches execute the insert statement in batches of batchSize, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
type InsertOnConflict ¶ added in v0.4.0
func (*InsertOnConflict[T]) DoNothing ¶ added in v0.4.0
func (insertOnConflict *InsertOnConflict[T]) DoNothing() *InsertExec[T]
DoNothing will not take any action, simply preventing an error from being responded.
func (*InsertOnConflict[T]) Set ¶ added in v0.4.0
func (insertOnConflict *InsertOnConflict[T]) Set(sets ...*Set[T]) *InsertOnConflictSet[T]
Set allows to specify which updates to perform.
func (*InsertOnConflict[T]) Update ¶ added in v0.4.0
func (insertOnConflict *InsertOnConflict[T]) Update(fields ...FieldOfModel[T]) *InsertExec[T]
Update will update the attributes specified by parameter with the values of the models that already exist.
func (*InsertOnConflict[T]) UpdateAll ¶ added in v0.4.0
func (insertOnConflict *InsertOnConflict[T]) UpdateAll() *InsertExec[T]
UpdateAll will update all model attributes with the values of the models that already exist.
type InsertOnConflictSet ¶ added in v0.4.0
func (*InsertOnConflictSet[T]) Exec ¶ added in v0.4.0
func (insertOnConflictSet *InsertOnConflictSet[T]) Exec() (int64, error)
Exec execute the insert statement, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
func (*InsertOnConflictSet[T]) ExecInBatches ¶ added in v0.4.0
func (insertOnConflictSet *InsertOnConflictSet[T]) ExecInBatches(batchSize int) (int64, error)
ExecInBatches execute the insert statement in batches of batchSize, returning the amount of rows inserted. It will also update the inserted model's primary key in their ids
WARNING: the value returned may depend on the db engine, for example mysql returns the double of the other ones when there is conflict
func (*InsertOnConflictSet[T]) Where ¶ added in v0.4.0
func (insertOnConflictSet *InsertOnConflictSet[T]) Where(conditions ...Condition[T]) *InsertExec[T]
Where allows to set conditions on the models that generate conflicts when performing the updates.
Available for: postgres, sqlite
type JoinCondition ¶
type JoinCondition[T model.Model] interface { Condition[T] // Preload activates the preloading of the joined model. Preload() JoinCondition[T] // contains filtered or unexported methods }
Condition that joins T with any other model
type LikeOperator ¶
type LikeOperator struct {
ValueOperator[string]
}
func Like ¶
func Like(pattern string) LikeOperator
Pattern in all databases:
- An underscore (_) in pattern stands for (matches) any single character.
- A percent sign (%) matches any sequence of zero or more characters.
Additionally in SQLServer:
- Square brackets ([ ]) matches any single character within the specified range ([a-f]) or set ([abcdef]).
- [^] matches any single character not within the specified range ([^a-f]) or set ([^abcdef]).
WARNINGS:
- SQLite: LIKE is case-insensitive unless case_sensitive_like pragma (https://www.sqlite.org/pragma.html#pragma_case_sensitive_like) is true.
- SQLServer, MySQL: the case-sensitivity depends on the collation used in compared column.
- PostgreSQL: LIKE is always case-sensitive, if you want case-insensitive use the ILIKE operator (implemented in psql.ILike)
refs:
- mysql: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like
- postgresql: https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
- sqlserver: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver16
- sqlite: https://www.sqlite.org/lang_expr.html#like
func NewLikeOperator ¶
func NewLikeOperator(sqlOperator sql.Operator, pattern string) LikeOperator
func (LikeOperator) Escape ¶
func (operator LikeOperator) Escape(escape rune) ValueOperator[string]
type NotUpdatableNumericField ¶ added in v0.2.1
type NotUpdatableNumericField[TModel model.Model, TAttribute Numeric] struct { Field[TModel, TAttribute] }
func (NotUpdatableNumericField[TModel, TAttribute]) Absolute ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Absolute() NotUpdatableNumericField[TModel, TAttribute]
Absolute calculates the absolute value of the value
func (NotUpdatableNumericField[TModel, TAttribute]) Aggregate ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Aggregate() NumericFieldAggregation
Aggregate allows applying aggregation functions to the field inside a group by
func (NotUpdatableNumericField[TModel, TAttribute]) And ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) And(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
And calculates the bitwise AND between value and other
func (NotUpdatableNumericField[TModel, TAttribute]) Divided ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Divided(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Divided divides value by other
func (NotUpdatableNumericField[TModel, TAttribute]) GetNumericValue ¶ added in v0.3.2
func (numericField NotUpdatableNumericField[TModel, TAttribute]) GetNumericValue() TAttribute
func (NotUpdatableNumericField[TModel, TAttribute]) GetValue ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) GetValue() float64
func (NotUpdatableNumericField[TModel, TAttribute]) Is ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Is() NumericFieldIs[TModel]
func (NotUpdatableNumericField[TModel, TAttribute]) Minus ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Minus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Minus subtracts other from the value
func (NotUpdatableNumericField[TModel, TAttribute]) Modulo ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Modulo(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Modulo returns the remainder of the entire division
func (NotUpdatableNumericField[TModel, TAttribute]) Not ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Not() NotUpdatableNumericField[TModel, TAttribute]
Not calculates the bitwise NOT of value
func (NotUpdatableNumericField[TModel, TAttribute]) Or ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Or(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
Or calculates the bitwise OR between value and other
func (NotUpdatableNumericField[TModel, TAttribute]) Plus ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Plus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Plus sums other to value
func (NotUpdatableNumericField[TModel, TAttribute]) Power ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Power(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Power elevates value to other
Warning: in sqlite DSQLITE_ENABLE_MATH_FUNCTIONS needs to be enabled or the error "no such function: POWER" will be returned
func (NotUpdatableNumericField[TModel, TAttribute]) ShiftLeft ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) ShiftLeft(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
ShiftLeft shifts value amount bits to the left
func (NotUpdatableNumericField[TModel, TAttribute]) ShiftRight ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) ShiftRight(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
ShiftRight shifts value amount bits to the right
func (NotUpdatableNumericField[TModel, TAttribute]) SquareRoot ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) SquareRoot() NotUpdatableNumericField[TModel, TAttribute]
SquareRoot calculates the square root of the value
Warning: in sqlite DSQLITE_ENABLE_MATH_FUNCTIONS needs to be enabled or the error "no such function: SQRT" will be returned
func (NotUpdatableNumericField[TModel, TAttribute]) Times ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Times(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Times multiplies value by other
func (NotUpdatableNumericField[TModel, TAttribute]) Xor ¶ added in v0.2.1
func (numericField NotUpdatableNumericField[TModel, TAttribute]) Xor(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
Xor calculates the bitwise XOR (exclusive OR) between value and other
Available for: postgres, mysql, sqlserver
type NotUpdatableStringField ¶ added in v0.2.1
func (NotUpdatableStringField[TModel]) Concat ¶ added in v0.2.1
func (stringField NotUpdatableStringField[TModel]) Concat(other ValueOfType[string]) NotUpdatableStringField[TModel]
Concat concatenates other to value
func (NotUpdatableStringField[TModel]) Is ¶ added in v0.2.1
func (stringField NotUpdatableStringField[TModel]) Is() StringFieldIs[TModel]
type NullableBoolField ¶ added in v0.0.2
func NewNullableBoolField ¶ added in v0.0.8
func NewNullableBoolField[TModel model.Model](name, column, columnPrefix string) NullableBoolField[TModel]
func (NullableBoolField[TModel]) Appearance ¶ added in v0.2.1
func (boolField NullableBoolField[TModel]) Appearance(number uint) NullableBoolField[TModel]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (NullableBoolField[TModel]) Set ¶ added in v0.2.1
func (boolField NullableBoolField[TModel]) Set() NullableFieldSet[TModel, bool]
type NullableField ¶ added in v0.0.2
type NullableField[TModel model.Model, TAttribute any] struct { UpdatableField[TModel, TAttribute] }
func NewNullableField ¶ added in v0.0.8
func NewNullableField[TModel model.Model, TAttribute any](name, column, columnPrefix string) NullableField[TModel, TAttribute]
func (NullableField[TModel, TAttribute]) Appearance ¶ added in v0.1.2
func (field NullableField[TModel, TAttribute]) Appearance(number uint) NullableField[TModel, TAttribute]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (NullableField[TModel, TAttribute]) Set ¶ added in v0.0.2
func (field NullableField[TModel, TAttribute]) Set() NullableFieldSet[TModel, TAttribute]
type NullableFieldSet ¶ added in v0.0.2
func (NullableFieldSet[TModel, TAttribute]) Null ¶ added in v0.0.2
func (set NullableFieldSet[TModel, TAttribute]) Null() *Set[TModel]
type NullableNumericField ¶ added in v0.0.10
type NullableNumericField[ TModel model.Model, TAttribute Numeric, ] struct { NumericField[TModel, TAttribute] }
func NewNullableNumericField ¶ added in v0.0.10
func NewNullableNumericField[ TModel model.Model, TAttribute Numeric, ](name, column, columnPrefix string) NullableNumericField[TModel, TAttribute]
func (NullableNumericField[TModel, TAttribute]) Appearance ¶ added in v0.1.2
func (field NullableNumericField[TModel, TAttribute]) Appearance(number uint) NullableNumericField[TModel, TAttribute]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (NullableNumericField[TModel, TAttribute]) Set ¶ added in v0.0.10
func (field NullableNumericField[TModel, TAttribute]) Set() NullableNumericFieldSet[TModel, TAttribute]
type NullableNumericFieldSet ¶ added in v0.2.1
type NullableNumericFieldSet[TModel model.Model, TAttribute Numeric] struct { NumericFieldSet[TModel, TAttribute] }
func (NullableNumericFieldSet[TModel, TAttribute]) Null ¶ added in v0.2.1
func (set NullableNumericFieldSet[TModel, TAttribute]) Null() *Set[TModel]
type NullableStringField ¶ added in v0.0.2
type NullableStringField[TModel model.Model] struct { StringField[TModel] }
func NewNullableStringField ¶ added in v0.0.8
func NewNullableStringField[TModel model.Model](name, column, columnPrefix string) NullableStringField[TModel]
func (NullableStringField[TModel]) Appearance ¶ added in v0.1.2
func (stringField NullableStringField[TModel]) Appearance(number uint) NullableStringField[TModel]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (NullableStringField[TModel]) Set ¶ added in v0.2.1
func (stringField NullableStringField[TModel]) Set() NullableFieldSet[TModel, string]
type Numeric ¶ added in v0.1.3
type Numeric interface {
constraints.Integer | constraints.Float
}
type NumericField ¶ added in v0.0.10
type NumericField[TModel model.Model, TAttribute Numeric] struct { UpdatableField[TModel, TAttribute] }
func NewNumericField ¶ added in v0.0.10
func NewNumericField[ TModel model.Model, TAttribute Numeric, ](name, column, columnPrefix string) NumericField[TModel, TAttribute]
func (NumericField[TModel, TAttribute]) Absolute ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Absolute() NotUpdatableNumericField[TModel, TAttribute]
Absolute calculates the absolute value of the value
func (NumericField[TModel, TAttribute]) Aggregate ¶ added in v0.1.3
func (numericField NumericField[TModel, TAttribute]) Aggregate() NumericFieldAggregation
Aggregate allows applying aggregation functions to the field inside a group by
func (NumericField[TModel, TAttribute]) And ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) And(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
And calculates the bitwise AND between value and other
func (NumericField[TModel, TAttribute]) Appearance ¶ added in v0.1.2
func (numericField NumericField[TModel, TAttribute]) Appearance(number uint) NumericField[TModel, TAttribute]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (NumericField[TModel, TAttribute]) Divided ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Divided(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Divided divides value by other
func (NumericField[TModel, TAttribute]) GetNumericValue ¶ added in v0.3.2
func (numericField NumericField[TModel, TAttribute]) GetNumericValue() TAttribute
func (NumericField[TModel, TAttribute]) GetValue ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) GetValue() float64
func (NumericField[TModel, TAttribute]) Is ¶ added in v0.2.0
func (numericField NumericField[TModel, TAttribute]) Is() NumericFieldIs[TModel]
func (NumericField[TModel, TAttribute]) Minus ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Minus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Minus subtracts other from the value
func (NumericField[TModel, TAttribute]) Modulo ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Modulo(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Modulo returns the remainder of the entire division
func (NumericField[TModel, TAttribute]) Not ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Not() NotUpdatableNumericField[TModel, TAttribute]
Not calculates the bitwise NOT of value
func (NumericField[TModel, TAttribute]) Or ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Or(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
Or calculates the bitwise OR between value and other
func (NumericField[TModel, TAttribute]) Plus ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Plus(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Plus sums other to value
func (NumericField[TModel, TAttribute]) Power ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Power(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Power elevates value to other
Warning: in sqlite DSQLITE_ENABLE_MATH_FUNCTIONS needs to be enabled or the error "no such function: POWER" will be returned
func (NumericField[TModel, TAttribute]) Set ¶ added in v0.0.10
func (numericField NumericField[TModel, TAttribute]) Set() NumericFieldSet[TModel, TAttribute]
func (NumericField[TModel, TAttribute]) ShiftLeft ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) ShiftLeft(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
ShiftLeft shifts value amount bits to the left
func (NumericField[TModel, TAttribute]) ShiftRight ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) ShiftRight(amount NumericOfType[int]) NotUpdatableNumericField[TModel, TAttribute]
ShiftRight shifts value amount bits to the right
func (NumericField[TModel, TAttribute]) SquareRoot ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) SquareRoot() NotUpdatableNumericField[TModel, TAttribute]
SquareRoot calculates the square root of the value
Warning: in sqlite DSQLITE_ENABLE_MATH_FUNCTIONS needs to be enabled or the error "no such function: SQRT" will be returned
func (NumericField[TModel, TAttribute]) Times ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Times(other ValueOfType[float64]) NotUpdatableNumericField[TModel, TAttribute]
Times multiplies value by other
func (NumericField[TModel, TAttribute]) Xor ¶ added in v0.2.1
func (numericField NumericField[TModel, TAttribute]) Xor(other NumericOfType[TAttribute]) NotUpdatableNumericField[TModel, TAttribute]
Xor calculates the bitwise XOR (exclusive OR) between value and other
Available for: postgres, mysql, sqlserver
type NumericFieldAggregation ¶ added in v0.1.3
type NumericFieldAggregation struct {
FieldAggregation[float64]
}
func (NumericFieldAggregation) And ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) And() AggregationResult[float64]
And calculates the bitwise AND of all non-null values (null values are ignored)
Not available for: sqlite, sqlserver
func (NumericFieldAggregation) Average ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) Average() AggregationResult[float64]
Average calculates the average (arithmetic mean) of all values
func (NumericFieldAggregation) Max ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) Max() AggregationResult[float64]
Max returns the maximum value of all values
func (NumericFieldAggregation) Min ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) Min() AggregationResult[float64]
Min returns the minimum value of all values
func (NumericFieldAggregation) Or ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) Or() AggregationResult[float64]
Or calculates the bitwise OR of all non-null values (null values are ignored)
Not available for: sqlite, sqlserver
func (NumericFieldAggregation) Sum ¶ added in v0.1.3
func (fieldAggregation NumericFieldAggregation) Sum() AggregationResult[float64]
Sum calculates the summation of all values
type NumericFieldIs ¶ added in v0.2.0
type NumericFieldSet ¶ added in v0.0.10
type NumericFieldSet[TModel model.Model, TAttribute Numeric] struct { // contains filtered or unexported fields }
func (NumericFieldSet[TModel, TAttribute]) Eq ¶ added in v0.0.10
func (set NumericFieldSet[TModel, TAttribute]) Eq(value ValueOfType[float64]) *Set[TModel]
func (NumericFieldSet[TModel, TAttribute]) Unsafe ¶ added in v0.0.10
func (set NumericFieldSet[TModel, TAttribute]) Unsafe(value IValue) *Set[TModel]
type NumericOfType ¶ added in v0.3.2
type NumericValue ¶ added in v0.1.3
type NumericValue[T Numeric] struct { Value T }
func Float32 ¶ added in v0.2.0
func Float32(value float32) NumericValue[float32]
func Float64 ¶ added in v0.2.0
func Float64(value float64) NumericValue[float64]
func Int ¶ added in v0.2.0
func Int(value int) NumericValue[int]
func Int16 ¶ added in v0.2.0
func Int16(value int16) NumericValue[int16]
func Int32 ¶ added in v0.2.0
func Int32(value int32) NumericValue[int32]
func Int64 ¶ added in v0.2.0
func Int64(value int64) NumericValue[int64]
func Int8 ¶ added in v0.2.0
func Int8(value int8) NumericValue[int8]
func UInt ¶ added in v0.2.0
func UInt(value uint) NumericValue[uint]
func UInt16 ¶ added in v0.2.0
func UInt16(value uint16) NumericValue[uint16]
func UInt32 ¶ added in v0.2.0
func UInt32(value uint32) NumericValue[uint32]
func UInt64 ¶ added in v0.2.0
func UInt64(value uint64) NumericValue[uint64]
func UInt8 ¶ added in v0.2.0
func UInt8(value uint8) NumericValue[uint8]
func UIntPTR ¶ added in v0.2.0
func UIntPTR(value uintptr) NumericValue[uintptr]
func (NumericValue[T]) GetNumericValue ¶ added in v0.3.2
func (numericValue NumericValue[T]) GetNumericValue() T
func (NumericValue[T]) GetValue ¶ added in v0.2.0
func (numericValue NumericValue[T]) GetValue() float64
type Operator ¶
type Operator[T any] interface { // Transform the Operator to a SQL string and a list of values to use in the query // columnName is used by the operator to determine which is the objective column. ToSQL(query *CQLQuery, columnName string) (string, []any, error) // This method is necessary to get the compiler to verify // that an object is of type Operator[T], // since if no method receives by parameter a type T, // any other Operator[T2] would also be considered a Operator[T]. InterfaceVerificationMethod(t T) }
func In ¶
func In[T any](values IValueList[T]) Operator[T]
func IsDistinct ¶
func IsNotDistinct ¶
func NotBetween ¶
Equivalent to NOT (v1 < value < v2)
func NotIn ¶
func NotIn[T any](values IValueList[T]) Operator[T]
type OrderLimitReturning ¶
func (*OrderLimitReturning[T]) Ascending ¶
func (olr *OrderLimitReturning[T]) Ascending(field IField)
Ascending specify an ascending order when updating models
available for: mysql
func (*OrderLimitReturning[T]) Descending ¶
func (olr *OrderLimitReturning[T]) Descending(field IField)
Descending specify a descending order when updating models
available for: mysql
func (*OrderLimitReturning[T]) Limit ¶
func (olr *OrderLimitReturning[T]) Limit(limit int)
Limit specify the number of models to be updated
Limit conditions can be cancelled by using `Limit(-1)`
available for: mysql
func (OrderLimitReturning[T]) Returning ¶
func (olr OrderLimitReturning[T]) Returning(dest *[]T)
available for: postgres, sqlite, sqlserver
warning: in sqlite preloads are not allowed
type PredicateOperator ¶
Operator that verifies a predicate Example: value IS TRUE
func NewPredicateOperator ¶
func NewPredicateOperator[T any](sqlOperator string) PredicateOperator[T]
func (PredicateOperator[T]) InterfaceVerificationMethod ¶
func (operator PredicateOperator[T]) InterfaceVerificationMethod(_ T)
type Query ¶
func (*Query[T]) Ascending ¶
Ascending specify an ascending order when retrieving models from database
func (*Query[T]) Count ¶ added in v0.0.6
Count returns the amount of models that fulfill the conditions
func (*Query[T]) Descending ¶
Descending specify a descending order when retrieving models from database
func (*Query[T]) FindOne ¶
FindOne finds the only one model that matches given conditions or returns error if 0 or more than 1 are found.
func (*Query[T]) First ¶
First finds the first model ordered by primary key, matching given conditions or returns gorm.ErrRecordNotFound is if no model does it
func (*Query[T]) GroupBy ¶ added in v0.1.3
func (query *Query[T]) GroupBy(fields ...IField) *QueryGroup
GroupBy arrange identical data into groups
func (*Query[T]) Last ¶
Last finds the last model ordered by primary key, matching given conditions or returns gorm.ErrRecordNotFound is if no model does it
func (*Query[T]) Limit ¶
Limit specify the number of models to be retrieved
Limit conditions can be cancelled by using `Limit(-1)`
type QueryGroup ¶ added in v0.1.3
type QueryGroup struct {
// contains filtered or unexported fields
}
func (*QueryGroup) Having ¶ added in v0.1.3
func (query *QueryGroup) Having(conditions ...AggregationCondition) *QueryGroup
Having allows filter groups of rows based on conditions involving aggregate functions
type StringField ¶
type StringField[TModel model.Model] struct { UpdatableField[TModel, string] }
func NewStringField ¶ added in v0.0.8
func NewStringField[TModel model.Model](name, column, columnPrefix string) StringField[TModel]
func (StringField[TModel]) Appearance ¶ added in v0.1.2
func (stringField StringField[TModel]) Appearance(number uint) StringField[TModel]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (StringField[TModel]) Concat ¶ added in v0.2.1
func (stringField StringField[TModel]) Concat(other ValueOfType[string]) NotUpdatableStringField[TModel]
Concat concatenates other to value
func (StringField[TModel]) Is ¶
func (stringField StringField[TModel]) Is() StringFieldIs[TModel]
type StringFieldIs ¶
func (StringFieldIs[TObject]) Like ¶
func (is StringFieldIs[TObject]) Like(pattern string) WhereCondition[TObject]
Pattern in all databases:
- An underscore (_) in pattern stands for (matches) any single character.
- A percent sign (%) matches any sequence of zero or more characters.
Additionally in SQLServer:
- Square brackets ([ ]) matches any single character within the specified range ([a-f]) or set ([abcdef]).
- [^] matches any single character not within the specified range ([^a-f]) or set ([^abcdef]).
WARNINGS:
- SQLite: LIKE is case-insensitive unless case_sensitive_like pragma (https://www.sqlite.org/pragma.html#pragma_case_sensitive_like) is true.
- SQLServer, MySQL: the case-sensitivity depends on the collation used in compared column.
- PostgreSQL: LIKE is always case-sensitive, if you want case-insensitive use the ILIKE operator (implemented in psql.ILike)
refs:
- mysql: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like
- postgresql: https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
- sqlserver: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver16
- sqlite: https://www.sqlite.org/lang_expr.html#like
type Table ¶
func (Table) DeliverTable ¶
Returns the related Table corresponding to the model
type UnsafeCondition ¶ added in v0.0.5
Condition that can be used to express conditions that are not supported (yet?) by cql Example: table1.columnX = table2.columnY
type UnsafeFieldIs ¶
type UnsafeFieldIs[TObject model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (UnsafeFieldIs[TObject, TAttribute]) Between ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Between(v1, v2 IValue) WhereCondition[TObject]
Equivalent to field1 < value < field2
func (UnsafeFieldIs[TObject, TAttribute]) Distinct ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Distinct(value IValue) WhereCondition[TObject]
func (UnsafeFieldIs[TObject, TAttribute]) Eq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Eq(value IValue) WhereCondition[TObject]
EqualTo
func (UnsafeFieldIs[TObject, TAttribute]) Gt ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Gt(value IValue) WhereCondition[TObject]
GreaterThan
func (UnsafeFieldIs[TObject, TAttribute]) GtOrEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) GtOrEq(value IValue) WhereCondition[TObject]
GreaterThanOrEqualTo
func (UnsafeFieldIs[TObject, TAttribute]) Lt ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Lt(value IValue) WhereCondition[TObject]
LessThan
func (UnsafeFieldIs[TObject, TAttribute]) LtOrEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) LtOrEq(value IValue) WhereCondition[TObject]
LessThanOrEqualTo
func (UnsafeFieldIs[TObject, TAttribute]) NotBetween ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotBetween(v1, v2 IValue) WhereCondition[TObject]
Equivalent to NOT (field1 < value < field2)
func (UnsafeFieldIs[TObject, TAttribute]) NotDistinct ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotDistinct(value IValue) WhereCondition[TObject]
func (UnsafeFieldIs[TObject, TAttribute]) NotEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotEq(value IValue) WhereCondition[TObject]
NotEqualTo
type UpdatableField ¶ added in v0.0.2
func NewUpdatableField ¶ added in v0.0.8
func NewUpdatableField[TModel model.Model, TAttribute any](name, column, columnPrefix string) UpdatableField[TModel, TAttribute]
func (UpdatableField[TModel, TAttribute]) Appearance ¶ added in v0.1.2
func (field UpdatableField[TModel, TAttribute]) Appearance(number uint) UpdatableField[TModel, TAttribute]
Appearance allows to choose which number of appearance use when field's model is joined more than once.
func (UpdatableField[TModel, TAttribute]) Set ¶ added in v0.0.2
func (field UpdatableField[TModel, TAttribute]) Set() FieldSet[TModel, TAttribute]
type Update ¶
type Update[T model.Model] struct { OrderLimitReturning[T] }
func (*Update[T]) Ascending ¶
Ascending specify an ascending order when updating models
available for: mysql
func (*Update[T]) Descending ¶
Descending specify a descending order when updating models
available for: mysql
func (*Update[T]) Limit ¶
Limit specify the number of models to be updated
Limit conditions can be cancelled by using `Limit(-1)`
available for: mysql
func (*Update[T]) Returning ¶
available for: postgres, sqlite, sqlserver
warning: in sqlite preloads are not allowed
type ValueOfType ¶ added in v0.0.10
type ValueOperator ¶
Operator that compares the value of the column against a fixed value If Operations has multiple entries, operations will be nested Example (single): value = v1 Example (multi): value LIKE v1 ESCAPE v2
func NewValueOperator ¶
func NewValueOperator[T any](sqlOperator sql.Operator, value IValue) *ValueOperator[T]
func (*ValueOperator[T]) AddOperation ¶
func (operator *ValueOperator[T]) AddOperation(sqlOperator any, value IValue) *ValueOperator[T]
func (ValueOperator[T]) InterfaceVerificationMethod ¶
func (operator ValueOperator[T]) InterfaceVerificationMethod(_ T)
type WhereCondition ¶
type WhereCondition[T model.Model] interface { Condition[T] // contains filtered or unexported methods }
Conditions that can be used in a where clause (or in a on of a join)
func And ¶
func And[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
func NewConnectionCondition ¶
func NewConnectionCondition[T model.Model](connector sql.Operator, conditions []WhereCondition[T]) WhereCondition[T]
Condition that connects multiple conditions. Example: condition1 AND condition2
func NewContainerCondition ¶
func NewContainerCondition[T model.Model](prefix sql.Operator, conditions []WhereCondition[T]) WhereCondition[T]
Condition that contains a internal condition. Example: NOT (internal condition)
func NewFieldCondition ¶
func Not ¶ added in v0.0.6
func Not[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
func Or ¶ added in v0.0.14
func Or[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
Source Files
¶
- collection.go
- collection_preload_condition.go
- condition.go
- connection_condition.go
- container_condition.go
- cql_query.go
- delete.go
- errors.go
- exists_condition.go
- field.go
- field_aggregation.go
- field_condition.go
- field_is.go
- field_is_unsafe.go
- insert.go
- invalid_condition.go
- join_condition.go
- logical.go
- operator.go
- operators.go
- order_limit_returning.go
- predicate_operator.go
- preload_condition.go
- query.go
- query_group.go
- select.go
- table.go
- types.go
- unsafe_condition.go
- update.go
- value_operator.go
- values.go
- where_condition.go