Documentation ¶
Index ¶
- Variables
- func And[T model.Model](conditions ...condition.WhereCondition[T]) condition.WhereCondition[T]
- func Delete[T model.Model](tx *gorm.DB, conditions ...condition.Condition[T]) *condition.Delete[T]
- func Not[T model.Model](conditions ...condition.WhereCondition[T]) condition.WhereCondition[T]
- func Open(dialector gorm.Dialector, opts ...gorm.Option) (*gorm.DB, error)
- func Or[T model.Model](conditions ...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 Update[T model.Model](tx *gorm.DB, conditions ...condition.Condition[T]) *condition.Update[T]
Constants ¶
This section is empty.
Variables ¶
var ( // query ErrFieldModelNotConcerned = condition.ErrFieldModelNotConcerned ErrJoinMustBeSelected = condition.ErrJoinMustBeSelected // conditions ErrEmptyConditions = condition.ErrEmptyConditions ErrOnlyPreloadsAllowed = condition.ErrOnlyPreloadsAllowed // crud ErrMoreThanOneObjectFound = condition.ErrMoreThanOneObjectFound ErrObjectNotFound = condition.ErrObjectNotFound // database ErrUnsupportedByDatabase = condition.ErrUnsupportedByDatabase ErrOrderByMustBeCalled = condition.ErrOrderByMustBeCalled // preload ErrRelationNotLoaded = preload.ErrRelationNotLoaded )
Functions ¶
func And ¶
func And[T model.Model](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 ¶
Create a Delete to which the conditions are applied inside transaction tx
For details see https://compiledquerylenguage.readthedocs.io/en/latest/cql/delete.html
func Not ¶
func Not[T model.Model](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](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
Types ¶
This section is empty.