Documentation
¶
Overview ¶
* Licensed to the AcmeStack under one or more contributor license * agreements. See the NOTICE file distributed with this work for * additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- func As(columnName any, asName any) string
- func Begin(opts ...*sql.TxOptions) *gorm.DB
- func Cache(models ...any)
- func Delete[T any](q *QueryCond[T], opts ...OptionFunc) *gorm.DB
- func DeleteById[T any](id any, opts ...OptionFunc) *gorm.DB
- func DeleteByIds[T any](ids any, opts ...OptionFunc) *gorm.DB
- func Exists[T any](q *QueryCond[T], opts ...OptionFunc) (bool, *gorm.DB)
- func GetModel[T any]() *T
- func Init(db *gorm.DB)
- func Insert[T any](entity *T, opts ...OptionFunc) *gorm.DB
- func InsertBatch[T any](entities []*T, opts ...OptionFunc) *gorm.DB
- func InsertBatchSize[T any](entities []*T, batchSize int, opts ...OptionFunc) *gorm.DB
- func LikeLeft(query *QueryCond[any], name string, value any)
- func LikeRight(query *QueryCond[any], name string, value any)
- func SelectById[T any](id any, opts ...OptionFunc) (*T, *gorm.DB)
- func SelectByIds[T any](ids any, opts ...OptionFunc) ([]*T, *gorm.DB)
- func SelectCount[T any](q *QueryCond[T], opts ...OptionFunc) (int64, *gorm.DB)
- func SelectGeneric[T any, R any](q *QueryCond[T], opts ...OptionFunc) (R, *gorm.DB)
- func SelectList[T any](q *QueryCond[T], opts ...OptionFunc) ([]*T, *gorm.DB)
- func SelectOne[T any](q *QueryCond[T], opts ...OptionFunc) (*T, *gorm.DB)
- func Update[T any](q *QueryCond[T], opts ...OptionFunc) *gorm.DB
- func UpdateById[T any](entity *T, opts ...OptionFunc) *gorm.DB
- func UpdateZeroById[T any](entity *T, opts ...OptionFunc) *gorm.DB
- type Condition
- type Dao
- type Function
- func (f *Function) As(asName any) string
- func (f *Function) Between(start int64, end int64) (string, int64, int64)
- func (f *Function) Eq(value int64) (string, int64)
- func (f *Function) Ge(value int64) (string, int64)
- func (f *Function) Gt(value int64) (string, int64)
- func (f *Function) In(values ...any) (string, []any)
- func (f *Function) Le(value int64) (string, int64)
- func (f *Function) Lt(value int64) (string, int64)
- func (f *Function) Ne(value int64) (string, int64)
- func (f *Function) NotBetween(start int64, end int64) (string, int64, int64)
- func (f *Function) NotIn(values ...any) (string, []any)
- type Option
- type OptionFunc
- type Page
- type QueryCond
- func (q *QueryCond[T]) And(fn ...func(q *QueryCond[T])) *QueryCond[T]
- func (q *QueryCond[T]) Between(column any, start, end any) *QueryCond[T]
- func (q *QueryCond[T]) Distinct(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) Eq(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Ge(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Group(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) Gt(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Having(having string, args ...any) *QueryCond[T]
- func (q *QueryCond[T]) In(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) IsNotNull(column any) *QueryCond[T]
- func (q *QueryCond[T]) IsNull(column any) *QueryCond[T]
- func (q *QueryCond[T]) Le(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Like(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeLeft(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeRight(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Lt(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Ne(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotBetween(column any, start, end any) *QueryCond[T]
- func (q *QueryCond[T]) NotIn(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLike(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeLeft(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeRight(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Omit(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) Or(fn ...func(q *QueryCond[T])) *QueryCond[T]
- func (q *QueryCond[T]) OrderByAsc(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) OrderByDesc(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) Select(columns ...any) *QueryCond[T]
- func (q *QueryCond[T]) Set(column any, val any) *QueryCond[T]
- type SqlSegment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteByIds ¶
func DeleteByIds[T any](ids any, opts ...OptionFunc) *gorm.DB
DeleteByIds 根据 ID 批量删除记录
func InsertBatch ¶
func InsertBatch[T any](entities []*T, opts ...OptionFunc) *gorm.DB
InsertBatch 批量插入多条记录
func InsertBatchSize ¶
func InsertBatchSize[T any](entities []*T, batchSize int, opts ...OptionFunc) *gorm.DB
InsertBatchSize 批量插入多条记录
func SelectById ¶
func SelectById[T any](id any, opts ...OptionFunc) (*T, *gorm.DB)
SelectById 根据 ID 查询单条记录
func SelectByIds ¶
func SelectByIds[T any](ids any, opts ...OptionFunc) ([]*T, *gorm.DB)
SelectByIds 根据 ID 查询多条记录
func SelectCount ¶
SelectCount 根据条件查询记录数量
func SelectGeneric ¶ added in v0.1.0
SelectGeneric 根据传入的泛型封装记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
func SelectList ¶
func SelectList[T any](q *QueryCond[T], opts ...OptionFunc) ([]*T, *gorm.DB)
SelectList 根据条件查询多条记录
func SelectOne ¶
func SelectOne[T any](q *QueryCond[T], opts ...OptionFunc) (*T, *gorm.DB)
SelectOne 根据条件查询单条记录
func UpdateById ¶
func UpdateById[T any](entity *T, opts ...OptionFunc) *gorm.DB
UpdateById 根据 ID 更新,默认零值不更新
func UpdateZeroById ¶ added in v0.1.0
func UpdateZeroById[T any](entity *T, opts ...OptionFunc) *gorm.DB
UpdateZeroById 根据 ID 零值更新
Types ¶
type Function ¶ added in v0.1.0
type Function struct {
// contains filtered or unexported fields
}
func (*Function) NotBetween ¶ added in v0.1.0
type OptionFunc ¶ added in v0.1.0
type OptionFunc func(*Option)
func IgnoreTotal ¶ added in v0.1.0
func IgnoreTotal() OptionFunc
IgnoreTotal 分页查询忽略总数 issue: https://github.com/acmestack/gorm-plus/issues/37
type Page ¶
func SelectPage ¶
SelectPage 根据条件分页查询记录
func SelectPageGeneric ¶ added in v0.1.0
func SelectPageGeneric[T any, R any](page *Page[R], q *QueryCond[T], opts ...OptionFunc) (*Page[R], *gorm.DB)
SelectPageGeneric 根据传入的泛型封装分页记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
type QueryCond ¶ added in v0.1.0
type QueryCond[T any] struct { // contains filtered or unexported fields }
func NewQueryModel ¶ added in v0.1.0
NewQueryModel 构建查询条件
func (*QueryCond[T]) NotBetween ¶ added in v0.1.0
NotBetween NOT BETWEEN 值1 AND 值2
func (*QueryCond[T]) NotLikeLeft ¶ added in v0.1.5
NotLikeLeft 非左模糊 NOT LIKE '%值'
func (*QueryCond[T]) NotLikeRight ¶ added in v0.1.5
NotLikeRight 非右模糊 NOT LIKE '值%'
func (*QueryCond[T]) OrderByAsc ¶ added in v0.1.0
OrderByAsc 排序:ORDER BY 字段1,字段2 ASC
func (*QueryCond[T]) OrderByDesc ¶ added in v0.1.0
OrderByDesc 排序:ORDER BY 字段1,字段2 Desc
type SqlSegment ¶ added in v0.1.5
type SqlSegment interface {
// contains filtered or unexported methods
}