Documentation
¶
Index ¶
- Variables
- func And[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func AndHaving(firstCondition condition.AggregationCondition, ...) condition.AggregationCondition
- func Bool(value bool) condition.BoolValue
- func ByteArray(value []byte) condition.Value[[]byte]
- func CountAll() condition.AggregationResult[float64]
- func Delete[T model.Model](tx *gorm.DB, firstCondition condition.Condition[T], ...) *condition.Delete[T]
- func Float32(value float32) condition.NumericValue[float32]
- func Float64(value float64) condition.NumericValue[float64]
- func Int(value int) condition.NumericValue[int]
- func Int8(value int8) condition.NumericValue[int8]
- func Int16(value int16) condition.NumericValue[int16]
- func Int32(value int32) condition.NumericValue[int32]
- func Int64(value int64) condition.NumericValue[int64]
- func Not[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func NotHaving(firstCondition condition.AggregationCondition, ...) condition.AggregationCondition
- func Open(dialector gorm.Dialector, opts ...gorm.Option) (*gorm.DB, error)
- func Or[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func OrHaving(firstCondition condition.AggregationCondition, ...) condition.AggregationCondition
- func Query[T model.Model](tx *gorm.DB, conditions ...condition.Condition[T]) *condition.Query[T]
- func String(value string) condition.Value[string]
- func Time(value time.Time) condition.Value[time.Time]
- func Transaction[RT any](db *gorm.DB, toExec func(*gorm.DB) (RT, error), opts ...*sql.TxOptions) (RT, error)
- func True[T model.Model]() condition.Condition[T]
- func UInt(value uint) condition.NumericValue[uint]
- func UInt8(value uint8) condition.NumericValue[uint8]
- func UInt16(value uint16) condition.NumericValue[uint16]
- func UInt32(value uint32) condition.NumericValue[uint32]
- func UInt64(value uint64) condition.NumericValue[uint64]
- func UIntPTR(value uintptr) condition.NumericValue[uintptr]
- func UUID(value model.UUID) condition.Value[model.UUID]
- func Update[T model.Model](tx *gorm.DB, firstCondition condition.Condition[T], ...) *condition.Update[T]
Constants ¶
This section is empty.
Variables ¶
var ( ErrFieldModelNotConcerned = condition.ErrFieldModelNotConcerned ErrAppearanceMustBeSelected = condition.ErrAppearanceMustBeSelected ErrAppearanceOutOfRange = condition.ErrAppearanceOutOfRange ErrMoreThanOneObjectFound = condition.ErrMoreThanOneObjectFound ErrObjectNotFound = condition.ErrObjectNotFound ErrUnsupportedByDatabase = condition.ErrUnsupportedByDatabase ErrOrderByMustBeCalled = condition.ErrOrderByMustBeCalled ErrOnlyPreloadsAllowed = condition.ErrOnlyPreloadsAllowed ErrRelationNotLoaded = preload.ErrRelationNotLoaded )
Functions ¶
func And ¶
func And[T model.Model](firstCondition condition.WhereCondition[T], conditions ...condition.WhereCondition[T]) condition.WhereCondition[T]
And allows the connection of multiple conditions by the AND logical connector.
Its use is optional as it is the default connector.
Example:
cql.And(conditions.City.Name.Is().Eq("Paris"), conditions.City.ZipCode.Is().Eq("75000"))
func AndHaving ¶ added in v0.1.3
func AndHaving(firstCondition condition.AggregationCondition, conditions ...condition.AggregationCondition) condition.AggregationCondition
AndHaving allows the connection of multiple conditions by the AND logical connector.
Its use is optional as it is the default connector.
func CountAll ¶ added in v0.1.3
func CountAll() condition.AggregationResult[float64]
CountAll is an Aggregation that returns the number of values (including nulls)
Example:
cql.Query[models.Product](db).GroupBy(conditions.Product.Int).Select(cql.CountAll(), "aggregation").Into(&results)
func Delete ¶
func Delete[T model.Model](tx *gorm.DB, firstCondition condition.Condition[T], conditions ...condition.Condition[T]) *condition.Delete[T]
Create a Delete to which the conditions are applied inside transaction tx.
At least one condition is required to avoid deleting all values in a table. In case this is the desired behavior, use cql.True.
For details see https://compiledquerylenguage.readthedocs.io/en/latest/cql/delete.html
func Not ¶
func Not[T model.Model](firstCondition condition.WhereCondition[T], conditions ...condition.WhereCondition[T]) condition.WhereCondition[T]
Not allows the negation of the conditions within it. Multiple conditions are connected by an AND by default.
Example:
cql.Not(conditions.City.Name.Is().Eq("Paris"), conditions.City.Name.Is().Eq("Buenos Aires"))
translates as
NOT (name = "Paris" AND name = "Buenos Aires")
func NotHaving ¶ added in v0.1.3
func NotHaving(firstCondition condition.AggregationCondition, conditions ...condition.AggregationCondition) condition.AggregationCondition
NotHaving allows the negation of the conditions within it. Multiple conditions are connected by an AND by default.
func Open ¶
Open initialize db session based on dialector
For details see https://compiledquerylenguage.readthedocs.io/en/latest/cql/connecting_to_a_database.html
func Or ¶
func Or[T model.Model](firstCondition condition.WhereCondition[T], conditions ...condition.WhereCondition[T]) condition.WhereCondition[T]
Or allows the connection of multiple conditions by the OR logical connector.
Example:
cql.Or(conditions.City.Name.Is().Eq("Paris"), conditions.City.Name.Is().Eq("Buenos Aires"))
func OrHaving ¶ added in v0.1.3
func OrHaving(firstCondition condition.AggregationCondition, conditions ...condition.AggregationCondition) condition.AggregationCondition
OrHaving allows the connection of multiple conditions by the OR logical connector.
func Query ¶
Create a Query to which the conditions are applied inside transaction tx
For details see https://compiledquerylenguage.readthedocs.io/en/latest/cql/query.html
func Transaction ¶
func Transaction[RT any]( db *gorm.DB, toExec func(*gorm.DB) (RT, error), opts ...*sql.TxOptions, ) (RT, error)
Executes the function "toExec" inside a transaction The transaction is automatically rolled back in case "toExec" returns an error opts can be used to pass arguments to the transaction
func True ¶ added in v0.0.12
True represents a condition that is always true.
In general, it should not be used. It can only be useful in case you want to perform an operation on all models in a table.
func Update ¶
func Update[T model.Model](tx *gorm.DB, firstCondition condition.Condition[T], conditions ...condition.Condition[T]) *condition.Update[T]
Create a Update to which the conditions are applied inside transaction tx.
At least one condition is required to avoid updating all values in a table. In case this is the desired behavior, use cql.True.
For details see https://compiledquerylenguage.readthedocs.io/en/latest/cql/update.html
Types ¶
This section is empty.