Documentation
¶
Index ¶
- Variables
- func Count[T any](tx *gorm.DB, cls *Clause) (int64, error)
- func Delete[T any](tx *gorm.DB, record *T) error
- func DeleteAll[T any](tx *gorm.DB, records []T) error
- func DeleteBy[T any](tx *gorm.DB, cls *Clause) error
- func FindAll[T any](tx *gorm.DB, cls *Clause) ([]T, error)
- func FindOne[T any](tx *gorm.DB, cls *Clause) (*T, error)
- func Save[T any](tx *gorm.DB, record *T) (*T, error)
- func SaveAll[T any](tx *gorm.DB, records []T) ([]T, error)
- type Clause
- func And(children ...*Clause) *Clause
- func Between(field string, from, to any, includeEdgeTo ...bool) *Clause
- func DecryptEq(field string, value any) *Clause
- func DecryptIn(field string, value ...any) *Clause
- func DecryptLike(field string, value any) *Clause
- func DecryptNeq(field string, value any) *Clause
- func DecryptNotIn(field string, value ...any) *Clause
- func DecryptNotLike(field string, value any) *Clause
- func DecryptNotSimilar(field string, value any) *Clause
- func DecryptSimilar(field string, value any) *Clause
- func Eq(field string, value any) *Clause
- func Gt(field string, value any) *Clause
- func Gte(field string, value any) *Clause
- func In(field string, value ...any) *Clause
- func IsNotNull(field string) *Clause
- func IsNull(field string) *Clause
- func Like(field string, value any) *Clause
- func Lt(field string, value any) *Clause
- func Lte(field string, value any) *Clause
- func Neq(field string, value any) *Clause
- func NotBetween(field string, from, to any, includeEdgeTo ...bool) *Clause
- func NotIn(field string, value ...any) *Clause
- func NotLike(field string, value any) *Clause
- func NotSimilar(field string, value any) *Clause
- func Or(children ...*Clause) *Clause
- func Similar(field string, value any) *Clause
- type Pagination
- type Sorting
Constants ¶
This section is empty.
Variables ¶
var (
GORM_ENCRYPT_KEY = os.Getenv("GORM_ENCRYPT_KEY")
)
Functions ¶
Types ¶
type Clause ¶
type Clause struct {
Field string `json:"field"`
Operator string `json:"operator"`
Value any `json:"value"`
Encrypted bool `json:"encrypted"`
Children []*Clause `json:"children"`
}
func DecryptIn ¶
DecryptIn creates a new clause with operator `IN` and the values decrypted. Please only use on string values.
func DecryptLike ¶
DecryptLike creates a new clause with operator `LIKE` and the value decrypted.
func DecryptNeq ¶
DecryptNeq creates a new clause with operator `<>` and the value decrypted.
func DecryptNotIn ¶
DecryptNotIn creates a new clause with operator `NOT IN` and the values decrypted. Please only use on string values.
func DecryptNotLike ¶
DecryptNotLike creates a new clause with operator `NOT LIKE` and the value decrypted.
func DecryptNotSimilar ¶
DecryptNotSimilar creates a new clause with operator "NOT LIKE" and the value "%value%" decrypted.
func DecryptSimilar ¶
DecryptSimilar creates a new clause with operator "LIKE" and the value "%value%" decrypted.
func NotBetween ¶
NotBetween creates a new clause that checks if a field is not between two values.
func NotSimilar ¶
NotSimilar creates a new clause with operator "NOT LIKE" and the value "%value%".
type Pagination ¶
type Pagination struct {
Page int `json:"page" form:"page"`
Size int `json:"size" form:"size"`
Total int64 `json:"total" form:"-"`
}
func FindAllComplex ¶
func FindAllComplex[T any](tx *gorm.DB, cls *Clause, p *Pagination, s *Sorting) ([]T, *Pagination, error)
FindAllComplex finds all records from the database with pagination and sorting.