Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyWhereCondition[T model.Model](condition WhereCondition[T], query *GormQuery, table Table) error
- func GetJoinNumber(joinNumberList []uint) int
- type BoolField
- 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 Collection
- func (collection Collection[TObject, TAttribute]) All(conditions ...WhereCondition[TAttribute]) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) Any(conditions ...WhereCondition[TAttribute]) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) None(conditions ...WhereCondition[TAttribute]) WhereCondition[TObject]
- func (collection Collection[TObject, TAttribute]) Preload(nestedPreloads ...JoinCondition[TAttribute]) Condition[TObject]
- type Condition
- type Delete
- func (deleteS *Delete[T]) Ascending(field IField, joinNumber ...uint) *Delete[T]
- func (deleteS *Delete[T]) Descending(field IField, joinNumber ...uint) *Delete[T]
- func (deleteS *Delete[T]) Exec() (int64, error)
- func (deleteS *Delete[T]) Limit(limit int) *Delete[T]
- func (deleteS *Delete[T]) Returning(dest *[]T) *Delete[T]
- type DynamicCondition
- type DynamicFieldIs
- func (is DynamicFieldIs[TObject, TAttribute]) Between(value1, value2 ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) Distinct(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) Eq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) Gt(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) Lt(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) NotBetween(value1, value2 ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- func (is DynamicFieldIs[TObject, TAttribute]) NotEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
- type DynamicOperator
- type Field
- func (field Field[TModel, TAttribute]) Is() FieldIs[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) IsDynamic() DynamicFieldIs[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) IsUnsafe() UnsafeFieldIs[TModel, TAttribute]
- func (field Field[TModel, TAttribute]) Value() *FieldValue[TModel, TAttribute]
- type FieldIs
- func (is FieldIs[TObject, TAttribute]) Between(v1, v2 TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Custom(op Operator[TAttribute]) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Distinct(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Eq(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Gt(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) GtOrEq(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) In(values ...TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Lt(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) LtOrEq(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotBetween(v1, v2 TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotDistinct(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotEq(value TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotIn(values ...TAttribute) WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) NotNull() WhereCondition[TObject]
- func (is FieldIs[TObject, TAttribute]) Null() WhereCondition[TObject]
- type FieldSet
- type FieldValue
- type GormQuery
- func (query *GormQuery) AddConcernedModel(model model.Model, table Table)
- func (query *GormQuery) AddSelect(table Table, fieldID IField)
- func (query GormQuery) ColumnName(table Table, fieldName string) string
- func (query *GormQuery) Count() (int64, error)
- func (query *GormQuery) Delete() (int64, error)
- func (query GormQuery) Dialector() sql.Dialector
- func (query *GormQuery) Find(dest any) error
- func (query *GormQuery) First(dest any) error
- func (query *GormQuery) GetModelTable(field IField, joinNumber int) (Table, error)
- func (query *GormQuery) GetTables(modelType reflect.Type) []Table
- func (query *GormQuery) Joins(joinQuery string, isLeftJoin bool, args ...interface{})
- func (query *GormQuery) Last(dest any) error
- func (query *GormQuery) Limit(limit int)
- func (query *GormQuery) Offset(offset int)
- func (query *GormQuery) Order(field IField, descending bool, joinNumber int) error
- func (query *GormQuery) Preload(preloadQuery string, args ...interface{})
- func (query *GormQuery) Returning(dest any) error
- func (query *GormQuery) Take(dest any) error
- func (query *GormQuery) Unscoped()
- func (query *GormQuery) Update(sets []ISet) (int64, error)
- func (query *GormQuery) Where(whereQuery interface{}, args ...interface{})
- type IField
- type ISet
- type IValue
- type JoinCondition
- type LikeOperator
- type NullableBoolField
- type NullableField
- type NullableFieldSet
- type NullableNumericField
- type NullableStringField
- type NumericDynamicFieldIs
- func (is NumericDynamicFieldIs[TObject, TAttribute]) Between(value1, value2 ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) Distinct(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) Eq(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) Gt(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) Lt(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) NotBetween(value1, value2 ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[numeric]) DynamicCondition[TObject]
- func (is NumericDynamicFieldIs[TObject, TAttribute]) NotEq(value ValueOfType[numeric]) DynamicCondition[TObject]
- type NumericField
- func (numericField NumericField[TModel, TAttribute]) IsDynamic() NumericDynamicFieldIs[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Set() NumericFieldSet[TModel, TAttribute]
- func (numericField NumericField[TModel, TAttribute]) Value() *NumericFieldValue[TModel, TAttribute]
- type NumericFieldSet
- type NumericFieldValue
- func (value *NumericFieldValue[TModel, TAttribute]) Absolute() *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) And(other int) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Divided(other float64) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Minus(other float64) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Modulo(other int) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Not() *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Or(other int) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Plus(other float64) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Power(other float64) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) ShiftLeft(amount int) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) ShiftRight(amount int) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) SquareRoot() *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Times(other float64) *NumericFieldValue[TModel, TAttribute]
- func (value *NumericFieldValue[TModel, TAttribute]) Xor(other int) *NumericFieldValue[TModel, TAttribute]
- type Operator
- func Between[T any](v1, v2 any) Operator[T]
- func Eq[T any](value any) Operator[T]
- func Gt[T any](value any) Operator[T]
- func GtOrEq[T any](value any) Operator[T]
- func In[T any](values []T) Operator[T]
- func IsDistinct[T any](value any) Operator[T]
- func IsNotDistinct[T any](value any) Operator[T]
- func IsNotNull[T any]() Operator[T]
- func IsNull[T any]() Operator[T]
- func Lt[T any](value any) Operator[T]
- func LtOrEq[T any](value any) Operator[T]
- func NotBetween[T any](v1, v2 any) Operator[T]
- func NotEq[T any](value any) Operator[T]
- func NotIn[T any](values []T) Operator[T]
- type OrderLimitReturning
- type PredicateOperator
- type Query
- func (query *Query[T]) Ascending(field IField, joinNumber ...uint) *Query[T]
- func (query *Query[T]) Count() (int64, error)
- func (query *Query[T]) Descending(field IField, joinNumber ...uint) *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]) 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 Set
- type StringField
- type StringFieldIs
- type StringFieldValue
- type Table
- type TableAndValue
- type UnsafeCondition
- type UnsafeFieldIs
- func (is UnsafeFieldIs[TObject, TAttribute]) Between(v1, v2 any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Distinct(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Eq(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Gt(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) GtOrEq(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) Lt(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) LtOrEq(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotBetween(v1, v2 any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotDistinct(value any) DynamicCondition[TObject]
- func (is UnsafeFieldIs[TObject, TAttribute]) NotEq(value any) DynamicCondition[TObject]
- type UpdatableField
- type Update
- func (update *Update[T]) Ascending(field IField, joinNumber ...uint) *Update[T]
- func (update *Update[T]) Descending(field IField, joinNumber ...uint) *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 ValueOfType
- type ValueOperator
- func (operator *ValueOperator[T]) AddOperation(sqlOperator any, value any) *ValueOperator[T]
- func (operator ValueOperator[T]) InterfaceVerificationMethod(_ T)
- func (operator *ValueOperator[T]) SelectJoin(operationNumber, joinNumber uint) DynamicOperator[T]
- func (operator ValueOperator[T]) ToSQL(query *GormQuery, columnName string) (string, []any, error)
- 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 Not[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
Constants ¶
const UndefinedJoinNumber = -1
Variables ¶
var ( // query ErrFieldModelNotConcerned = errors.New("field's model is not concerned by the query (not joined)") ErrJoinMustBeSelected = errors.New("field's model is joined more than once, select which one you want to use") // conditions ErrEmptyConditions = errors.New("at least one condition is required") ErrOnlyPreloadsAllowed = errors.New("only conditions that do a preload are allowed") // crud 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") )
Functions ¶
func ApplyWhereCondition ¶
func ApplyWhereCondition[T model.Model](condition WhereCondition[T], query *GormQuery, table Table) error
apply WhereCondition of any type on the query
func GetJoinNumber ¶
from a list of uint, return the first or UndefinedJoinNumber in case the list is empty
Types ¶
type BoolField ¶
type BoolField[TModel model.Model] struct { UpdatableField[TModel, bool] }
func NewBoolField ¶ added in v0.0.8
func (BoolField[TModel]) Is ¶
func (boolField BoolField[TModel]) Is() BoolFieldIs[TModel]
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 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(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(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(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] }
func (*Delete[T]) Ascending ¶
Ascending specify an ascending order when updating models
joinNumber can be used to select the join in case the field is joined more than once
available for: mysql
func (*Delete[T]) Descending ¶
Descending specify a descending order when updating models
joinNumber can be used to select the join in case the field is joined more than once
available for: mysql
type DynamicCondition ¶
type DynamicCondition[T model.Model] interface { WhereCondition[T] // Allows to choose which number of join use // for the operation in position "operationNumber" // when the value is a field and its model is joined more than once. // Does nothing if the operationNumber is bigger than the amount of operations. SelectJoin(operationNumber, joinNumber uint) DynamicCondition[T] }
func NewFieldCondition ¶
type DynamicFieldIs ¶
type DynamicFieldIs[TObject model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (DynamicFieldIs[TObject, TAttribute]) Between ¶
func (is DynamicFieldIs[TObject, TAttribute]) Between(value1, value2 ValueOfType[TAttribute]) DynamicCondition[TObject]
Equivalent to field1 < value < field2
func (DynamicFieldIs[TObject, TAttribute]) Distinct ¶
func (is DynamicFieldIs[TObject, TAttribute]) Distinct(value ValueOfType[TAttribute]) DynamicCondition[TObject]
func (DynamicFieldIs[TObject, TAttribute]) Eq ¶
func (is DynamicFieldIs[TObject, TAttribute]) Eq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
EqualTo
func (DynamicFieldIs[TObject, TAttribute]) Gt ¶
func (is DynamicFieldIs[TObject, TAttribute]) Gt(value ValueOfType[TAttribute]) DynamicCondition[TObject]
GreaterThan
func (DynamicFieldIs[TObject, TAttribute]) GtOrEq ¶
func (is DynamicFieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
GreaterThanOrEqualTo
func (DynamicFieldIs[TObject, TAttribute]) Lt ¶
func (is DynamicFieldIs[TObject, TAttribute]) Lt(value ValueOfType[TAttribute]) DynamicCondition[TObject]
LessThan
func (DynamicFieldIs[TObject, TAttribute]) LtOrEq ¶
func (is DynamicFieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
LessThanOrEqualTo
func (DynamicFieldIs[TObject, TAttribute]) NotBetween ¶
func (is DynamicFieldIs[TObject, TAttribute]) NotBetween(value1, value2 ValueOfType[TAttribute]) DynamicCondition[TObject]
Equivalent to NOT (field1 < value < field2)
func (DynamicFieldIs[TObject, TAttribute]) NotDistinct ¶
func (is DynamicFieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[TAttribute]) DynamicCondition[TObject]
func (DynamicFieldIs[TObject, TAttribute]) NotEq ¶
func (is DynamicFieldIs[TObject, TAttribute]) NotEq(value ValueOfType[TAttribute]) DynamicCondition[TObject]
NotEqualTo
type DynamicOperator ¶
type DynamicOperator[T any] interface { Operator[T] // Allows to choose which number of join use // for the value in position "valueNumber" // when the value is a field and its model is joined more than once. // Does nothing if the valueNumber is bigger than the amount of values. SelectJoin(valueNumber, joinNumber uint) DynamicOperator[T] }
type Field ¶
func (Field[TModel, TAttribute]) Is ¶
Is allows creating conditions that include the field and a static value
func (Field[TModel, TAttribute]) IsDynamic ¶ added in v0.0.10
func (field Field[TModel, TAttribute]) IsDynamic() DynamicFieldIs[TModel, TAttribute]
IsDynamic allows creating conditions that include the field and other fields
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.
func (Field[TModel, TAttribute]) Value ¶ added in v0.0.10
func (field Field[TModel, TAttribute]) Value() *FieldValue[TModel, TAttribute]
Value allows using the value of the field inside dynamic conditions.
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 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 TAttribute) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) Eq ¶
func (is FieldIs[TObject, TAttribute]) Eq(value 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 TAttribute) WhereCondition[TObject]
GreaterThan
func (FieldIs[TObject, TAttribute]) GtOrEq ¶
func (is FieldIs[TObject, TAttribute]) GtOrEq(value TAttribute) WhereCondition[TObject]
GreaterThanOrEqualTo
func (FieldIs[TObject, TAttribute]) In ¶
func (is FieldIs[TObject, TAttribute]) In(values ...TAttribute) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) Lt ¶
func (is FieldIs[TObject, TAttribute]) Lt(value TAttribute) WhereCondition[TObject]
LessThan
func (FieldIs[TObject, TAttribute]) LtOrEq ¶
func (is FieldIs[TObject, TAttribute]) LtOrEq(value TAttribute) WhereCondition[TObject]
LessThanOrEqualTo
func (FieldIs[TObject, TAttribute]) NotBetween ¶
func (is FieldIs[TObject, TAttribute]) NotBetween(v1, v2 TAttribute) WhereCondition[TObject]
Equivalent to NOT (v1 < value < v2)
func (FieldIs[TObject, TAttribute]) NotDistinct ¶
func (is FieldIs[TObject, TAttribute]) NotDistinct(value TAttribute) WhereCondition[TObject]
func (FieldIs[TObject, TAttribute]) NotEq ¶
func (is FieldIs[TObject, TAttribute]) NotEq(value 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 ...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 FieldSet ¶
type FieldSet[TModel model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (FieldSet[TModel, TAttribute]) Dynamic ¶
func (set FieldSet[TModel, TAttribute]) Dynamic(value ValueOfType[TAttribute], joinNumber ...uint) *Set[TModel]
joinNumber can be used to select the join in case the field is joined more than once
type FieldValue ¶ added in v0.0.10
type FieldValue[TModel model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func NewFieldValue ¶ added in v0.0.10
func NewFieldValue[TModel model.Model, TAttribute any](field Field[TModel, TAttribute]) *FieldValue[TModel, TAttribute]
type GormQuery ¶
type GormQuery struct {
GormDB *gorm.DB
ConcernedModels map[reflect.Type][]Table
// contains filtered or unexported fields
}
func ApplyConditions ¶
Create a GormQuery to which the conditions are applied
func NewGormQuery ¶
func (*GormQuery) AddConcernedModel ¶
func (GormQuery) ColumnName ¶
func (*GormQuery) Count ¶ added in v0.0.6
Count returns the amount of models that fulfill the conditions
func (*GormQuery) First ¶
First finds the first record ordered by primary key, matching given conditions
func (*GormQuery) GetModelTable ¶
func (*GormQuery) Last ¶
Last finds the last record ordered by primary key, matching given conditions
func (*GormQuery) Limit ¶
Limit specify the number of records to be retrieved
Limit conditions can be cancelled by using `Limit(-1)`
func (*GormQuery) Offset ¶
Offset specify the number of records to skip before starting to return the records
Offset conditions can be cancelled by using `Offset(-1)`.
func (*GormQuery) Order ¶
Order specify order when retrieving models from database.
if descending is true, the ordering is in descending direction.
joinNumber can be used to select the join in case the field is joined more than once.
func (*GormQuery) Returning ¶
available for: postgres, sqlite, sqlserver
warning: in sqlite, sqlserver preloads are not allowed
func (*GormQuery) Take ¶
Take finds the first record returned by the database in no specified order, matching given conditions
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 NullableBoolField ¶ added in v0.0.2
type NullableBoolField[TModel model.Model] struct { NullableField[TModel, bool] }
func NewNullableBoolField ¶ added in v0.0.8
func NewNullableBoolField[TModel model.Model](name, column, columnPrefix string) NullableBoolField[TModel]
func (NullableBoolField[TModel]) Is ¶ added in v0.0.2
func (boolField NullableBoolField[TModel]) Is() BoolFieldIs[TModel]
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]) 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 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64, ] struct { NumericField[TModel, TAttribute] }
func NewNullableNumericField ¶ added in v0.0.10
func (NullableNumericField[TModel, TAttribute]) Set ¶ added in v0.0.10
func (field NullableNumericField[TModel, TAttribute]) Set() NullableFieldSet[TModel, TAttribute]
type NullableStringField ¶ added in v0.0.2
type NullableStringField[TModel model.Model] struct { NullableField[TModel, string] }
func NewNullableStringField ¶ added in v0.0.8
func NewNullableStringField[TModel model.Model](name, column, columnPrefix string) NullableStringField[TModel]
func (NullableStringField[TModel]) Is ¶ added in v0.0.2
func (stringField NullableStringField[TModel]) Is() StringFieldIs[TModel]
func (NullableStringField[TModel]) Value ¶ added in v0.0.11
func (stringField NullableStringField[TModel]) Value() *StringFieldValue[TModel]
Value allows using the value of the field inside dynamic conditions.
type NumericDynamicFieldIs ¶ added in v0.0.10
type NumericDynamicFieldIs[TObject model.Model, TAttribute any] struct { // contains filtered or unexported fields }
func (NumericDynamicFieldIs[TObject, TAttribute]) Between ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) Between(value1, value2 ValueOfType[numeric]) DynamicCondition[TObject]
Equivalent to field1 < value < field2
func (NumericDynamicFieldIs[TObject, TAttribute]) Distinct ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) Distinct(value ValueOfType[numeric]) DynamicCondition[TObject]
func (NumericDynamicFieldIs[TObject, TAttribute]) Eq ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) Eq(value ValueOfType[numeric]) DynamicCondition[TObject]
EqualTo
func (NumericDynamicFieldIs[TObject, TAttribute]) Gt ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) Gt(value ValueOfType[numeric]) DynamicCondition[TObject]
GreaterThan
func (NumericDynamicFieldIs[TObject, TAttribute]) GtOrEq ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) GtOrEq(value ValueOfType[numeric]) DynamicCondition[TObject]
GreaterThanOrEqualTo
func (NumericDynamicFieldIs[TObject, TAttribute]) Lt ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) Lt(value ValueOfType[numeric]) DynamicCondition[TObject]
LessThan
func (NumericDynamicFieldIs[TObject, TAttribute]) LtOrEq ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) LtOrEq(value ValueOfType[numeric]) DynamicCondition[TObject]
LessThanOrEqualTo
func (NumericDynamicFieldIs[TObject, TAttribute]) NotBetween ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) NotBetween(value1, value2 ValueOfType[numeric]) DynamicCondition[TObject]
Equivalent to NOT (field1 < value < field2)
func (NumericDynamicFieldIs[TObject, TAttribute]) NotDistinct ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) NotDistinct(value ValueOfType[numeric]) DynamicCondition[TObject]
func (NumericDynamicFieldIs[TObject, TAttribute]) NotEq ¶ added in v0.0.10
func (is NumericDynamicFieldIs[TObject, TAttribute]) NotEq(value ValueOfType[numeric]) DynamicCondition[TObject]
NotEqualTo
type NumericField ¶ added in v0.0.10
type NumericField[TModel model.Model, TAttribute int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64] struct { UpdatableField[TModel, TAttribute] }
func NewNumericField ¶ added in v0.0.10
func (NumericField[TModel, TAttribute]) IsDynamic ¶ added in v0.0.10
func (numericField NumericField[TModel, TAttribute]) IsDynamic() NumericDynamicFieldIs[TModel, TAttribute]
func (NumericField[TModel, TAttribute]) Set ¶ added in v0.0.10
func (numericField NumericField[TModel, TAttribute]) Set() NumericFieldSet[TModel, TAttribute]
func (NumericField[TModel, TAttribute]) Value ¶ added in v0.0.10
func (numericField NumericField[TModel, TAttribute]) Value() *NumericFieldValue[TModel, TAttribute]
Value allows using the value of the field inside dynamic conditions.
type NumericFieldSet ¶ added in v0.0.10
type NumericFieldSet[TModel model.Model, TAttribute int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64] struct { // contains filtered or unexported fields }
func (NumericFieldSet[TModel, TAttribute]) Dynamic ¶ added in v0.0.10
func (set NumericFieldSet[TModel, TAttribute]) Dynamic(value ValueOfType[numeric], joinNumber ...uint) *Set[TModel]
joinNumber can be used to select the join in case the field is joined more than once
func (NumericFieldSet[TModel, TAttribute]) Eq ¶ added in v0.0.10
func (set NumericFieldSet[TModel, TAttribute]) Eq(value TAttribute) *Set[TModel]
func (NumericFieldSet[TModel, TAttribute]) Unsafe ¶ added in v0.0.10
func (set NumericFieldSet[TModel, TAttribute]) Unsafe(value any) *Set[TModel]
type NumericFieldValue ¶ added in v0.0.10
type NumericFieldValue[TModel model.Model, TAttribute any] struct { FieldValue[TModel, TAttribute] }
func (*NumericFieldValue[TModel, TAttribute]) Absolute ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Absolute() *NumericFieldValue[TModel, TAttribute]
Absolute calculates the absolute value of the value
func (*NumericFieldValue[TModel, TAttribute]) And ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) And(other int) *NumericFieldValue[TModel, TAttribute]
And calculates the bitwise AND between value and other
func (*NumericFieldValue[TModel, TAttribute]) Divided ¶ added in v0.0.10
func (value *NumericFieldValue[TModel, TAttribute]) Divided(other float64) *NumericFieldValue[TModel, TAttribute]
Divided divides value by other
func (*NumericFieldValue[TModel, TAttribute]) Minus ¶ added in v0.0.10
func (value *NumericFieldValue[TModel, TAttribute]) Minus(other float64) *NumericFieldValue[TModel, TAttribute]
Minus subtracts other from the value
func (*NumericFieldValue[TModel, TAttribute]) Modulo ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Modulo(other int) *NumericFieldValue[TModel, TAttribute]
Modulo returns the remainder of the entire division
func (*NumericFieldValue[TModel, TAttribute]) Not ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Not() *NumericFieldValue[TModel, TAttribute]
Not calculates the bitwise NOT of value
func (*NumericFieldValue[TModel, TAttribute]) Or ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Or(other int) *NumericFieldValue[TModel, TAttribute]
Or calculates the bitwise OR between value and other
func (*NumericFieldValue[TModel, TAttribute]) Plus ¶ added in v0.0.10
func (value *NumericFieldValue[TModel, TAttribute]) Plus(other float64) *NumericFieldValue[TModel, TAttribute]
Plus sums other to value
func (*NumericFieldValue[TModel, TAttribute]) Power ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Power(other float64) *NumericFieldValue[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 (*NumericFieldValue[TModel, TAttribute]) ShiftLeft ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) ShiftLeft(amount int) *NumericFieldValue[TModel, TAttribute]
ShiftLeft shifts value amount bits to the left
func (*NumericFieldValue[TModel, TAttribute]) ShiftRight ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) ShiftRight(amount int) *NumericFieldValue[TModel, TAttribute]
ShiftRight shifts value amount bits to the right
func (*NumericFieldValue[TModel, TAttribute]) SquareRoot ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) SquareRoot() *NumericFieldValue[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 (*NumericFieldValue[TModel, TAttribute]) Times ¶ added in v0.0.10
func (value *NumericFieldValue[TModel, TAttribute]) Times(other float64) *NumericFieldValue[TModel, TAttribute]
Times multiplies value by other
func (*NumericFieldValue[TModel, TAttribute]) Xor ¶ added in v0.0.11
func (value *NumericFieldValue[TModel, TAttribute]) Xor(other int) *NumericFieldValue[TModel, TAttribute]
Xor calculates the bitwise XOR (exclusive OR) between value and other
Available for: postgres, mysql, sqlserver
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 *GormQuery, 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 IsDistinct ¶
func IsNotDistinct ¶
func NotBetween ¶
Equivalent to NOT (v1 < value < v2)
type OrderLimitReturning ¶
func (*OrderLimitReturning[T]) Ascending ¶
func (olr *OrderLimitReturning[T]) Ascending(field IField, joinNumber ...uint)
Ascending specify an ascending order when updating models
joinNumber can be used to select the join in case the field is joined more than once
available for: mysql
func (*OrderLimitReturning[T]) Descending ¶
func (olr *OrderLimitReturning[T]) Descending(field IField, joinNumber ...uint)
Descending specify a descending order when updating models
joinNumber can be used to select the join in case the field is joined more than once
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 joinNumber can be used to select the join in case the field is joined more than once
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 joinNumber can be used to select the join in case the field is joined more than once
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]) 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 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]) Is ¶
func (stringField StringField[TModel]) Is() StringFieldIs[TModel]
func (StringField[TModel]) Value ¶ added in v0.0.11
func (stringField StringField[TModel]) Value() *StringFieldValue[TModel]
Value allows using the value of the field inside dynamic conditions.
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 StringFieldValue ¶ added in v0.0.11
type StringFieldValue[TModel model.Model] struct { FieldValue[TModel, string] }
func (*StringFieldValue[TModel]) Concat ¶ added in v0.0.11
func (value *StringFieldValue[TModel]) Concat(other string) *StringFieldValue[TModel]
Concat concatenates other to value
type Table ¶
func (Table) DeliverTable ¶
func (t Table) DeliverTable(query *GormQuery, model model.Model, relationName string) (Table, error)
Returns the related Table corresponding to the model
type TableAndValue ¶
type TableAndValue struct {
// contains filtered or unexported fields
}
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 any) DynamicCondition[TObject]
Equivalent to field1 < value < field2
func (UnsafeFieldIs[TObject, TAttribute]) Distinct ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Distinct(value any) DynamicCondition[TObject]
func (UnsafeFieldIs[TObject, TAttribute]) Eq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Eq(value any) DynamicCondition[TObject]
EqualTo
func (UnsafeFieldIs[TObject, TAttribute]) Gt ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Gt(value any) DynamicCondition[TObject]
GreaterThan
func (UnsafeFieldIs[TObject, TAttribute]) GtOrEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) GtOrEq(value any) DynamicCondition[TObject]
GreaterThanOrEqualTo
func (UnsafeFieldIs[TObject, TAttribute]) Lt ¶
func (is UnsafeFieldIs[TObject, TAttribute]) Lt(value any) DynamicCondition[TObject]
LessThan
func (UnsafeFieldIs[TObject, TAttribute]) LtOrEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) LtOrEq(value any) DynamicCondition[TObject]
LessThanOrEqualTo
func (UnsafeFieldIs[TObject, TAttribute]) NotBetween ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotBetween(v1, v2 any) DynamicCondition[TObject]
Equivalent to NOT (field1 < value < field2)
func (UnsafeFieldIs[TObject, TAttribute]) NotDistinct ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotDistinct(value any) DynamicCondition[TObject]
func (UnsafeFieldIs[TObject, TAttribute]) NotEq ¶
func (is UnsafeFieldIs[TObject, TAttribute]) NotEq(value any) DynamicCondition[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]) 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
joinNumber can be used to select the join in case the field is joined more than once
available for: mysql
func (*Update[T]) Descending ¶
Descending specify a descending order when updating models
joinNumber can be used to select the join in case the field is joined more than once
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 any) *ValueOperator[T]
func (*ValueOperator[T]) AddOperation ¶
func (operator *ValueOperator[T]) AddOperation(sqlOperator any, value any) *ValueOperator[T]
func (ValueOperator[T]) InterfaceVerificationMethod ¶
func (operator ValueOperator[T]) InterfaceVerificationMethod(_ T)
func (*ValueOperator[T]) SelectJoin ¶
func (operator *ValueOperator[T]) SelectJoin(operationNumber, joinNumber uint) DynamicOperator[T]
Allows to choose which number of join use for the operation in position "operationNumber" when the value is a field and its model is joined more than once. Does nothing if the operationNumber is bigger than the amount of operations.
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 Not ¶ added in v0.0.6
func Not[T model.Model](conditions ...WhereCondition[T]) WhereCondition[T]
Source Files
¶
- collection.go
- collection_preload_condition.go
- condition.go
- connection_condition.go
- container_condition.go
- delete.go
- dynamic_condition.go
- errors.go
- exists_condition.go
- field.go
- field_condition.go
- field_is.go
- field_is_dynamic.go
- field_is_unsafe.go
- field_value.go
- gorm_query.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
- table.go
- unsafe_condition.go
- update.go
- value_operator.go
- where_condition.go