Documentation ¶
Index ¶
- Variables
- func And[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func Delete[T model.Model](tx *gorm.DB, firstCondition condition.Condition[T], ...) *condition.Delete[T]
- func Not[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func Open(dialector gorm.Dialector, opts ...gorm.Option) (*gorm.DB, error)
- func Or[T model.Model](firstCondition condition.WhereCondition[T], ...) condition.WhereCondition[T]
- func Query[T model.Model](tx *gorm.DB, conditions ...condition.Condition[T]) *condition.Query[T]
- 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 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 ErrFieldIsRepeated = condition.ErrFieldIsRepeated 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 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 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 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.