Documentation ¶
Index ¶
- Constants
- func Connect(silent ...bool) *connector
- func Count[T any](tx *gorm.DB, clause *Clause) (int64, error)
- func Delete[T any](tx *gorm.DB, model *T) error
- func DeleteAll[T any](tx *gorm.DB, models []T) error
- func DeleteAllByClause[T any](tx *gorm.DB, clause *Clause) error
- func FindAll[T any](tx *gorm.DB, clause *Clause) ([]T, error)
- func FindOne[T any](tx *gorm.DB, clause *Clause) (*T, error)
- func Save[T any](tx *gorm.DB, model *T) (*T, error)
- func SaveAll[T any](tx *gorm.DB, models []T) ([]T, error)
- type Clause
- func And(children ...*Clause) *Clause
- func Eq(field string, value interface{}) *Clause
- func Gt(field string, value interface{}) *Clause
- func Gte(field string, value interface{}) *Clause
- func In(field string, value ...interface{}) *Clause
- func IsNotNull(field string) *Clause
- func IsNull(field string) *Clause
- func Like(field string, value interface{}) *Clause
- func Lt(field string, value interface{}) *Clause
- func Lte(field string, value interface{}) *Clause
- func Neq(field string, value interface{}) *Clause
- func NewClause(field, operator string, value interface{}, children ...*Clause) *Clause
- func NotIn(field string, value ...interface{}) *Clause
- func NotLike(field string, value interface{}) *Clause
- func NotSimilar(field string, value string) *Clause
- func Or(children ...*Clause) *Clause
- func Similar(field string, value string) *Clause
- type Pagination
- type Sort
Constants ¶
View Source
const ( OPERATOR_EQUAL = "=" OPERATOR_NOT_EQUAL = "<>" OPERATOR_GREATER = ">" OPERATOR_LESS = "<" OPERATOR_GREATER_EQUAL = ">=" OPERATOR_LESS_EQUAL = "<=" OPERATOR_LIKE = "LIKE" OPERATOR_NOT_LIKE = "NOT LIKE" OPERATOR_IN = "IN" OPERATOR_NOT_IN = "NOT IN" OPERATOR_IS_NULL = "IS NULL" OPERATOR_IS_NOT_NULL = "IS NOT NULL" OPERATOR_AND = "AND" OPERATOR_OR = "OR" )
Variables ¶
This section is empty.
Functions ¶
func DeleteAllByClause ¶
DeleteAllByClause deletes all the models that match the given clause.
Types ¶
type Clause ¶
Clause is a struct that represents a clause in a SQL statement.
func NotSimilar ¶
NotSimilar creates a new Clause with the operator "NOT LIKE" and the value "%value%".
type Pagination ¶
type Pagination struct { Page int `form:"page" json:"page"` Size int `form:"size" json:"size"` Total int64 `json:"total"` // this field is used in response, not in query }
func FindAllComplex ¶
func FindAllComplex[T any](tx *gorm.DB, clause *Clause, sort *Sort, pagination *Pagination) ([]T, *Pagination, error)
FindAllComplex finds all records that match the given clause and applies the given sort and pagination.
func Page ¶
func Page(page int, size int) *Pagination
Click to show internal directories.
Click to hide internal directories.