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) *gobatis.DB
- func Cache(models ...any)
- func Delete[T any](q *QueryCond[T], opts ...OptionFunc) *gobatis.DB
- func DeleteById[T any](id any, opts ...OptionFunc) *gobatis.DB
- func DeleteByIds[T any](ids any, opts ...OptionFunc) *gobatis.DB
- func Exists[T any](q *QueryCond[T], opts ...OptionFunc) (bool, *gobatis.DB)
- func GetModel[T any]() *T
- func Init(db *gobatis.DB)
- func Insert[T any](entity *T, opts ...OptionFunc) *gobatis.DB
- func InsertBatch[T any](entities []*T, opts ...OptionFunc) *gobatis.DB
- func InsertBatchSize[T any](entities []*T, batchSize int, opts ...OptionFunc) *gobatis.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, *gobatis.DB)
- func SelectByIds[T any](ids any, opts ...OptionFunc) ([]*T, *gobatis.DB)
- func SelectCount[T any](q *QueryCond[T], opts ...OptionFunc) (int64, *gobatis.DB)
- func SelectGeneric[T any, R any](q *QueryCond[T], opts ...OptionFunc) (R, *gobatis.DB)
- func SelectList[T any](q *QueryCond[T], opts ...OptionFunc) ([]*T, *gobatis.DB)
- func SelectOne[T any](q *QueryCond[T], opts ...OptionFunc) (*T, *gobatis.DB)
- func Tx(txFunc func(tx *gobatis.DB) error, opts ...OptionFunc) error
- func Update[T any](q *QueryCond[T], opts ...OptionFunc) *gobatis.DB
- func UpdateById[T any](entity *T, opts ...OptionFunc) *gobatis.DB
- func UpdateZeroById[T any](entity *T, opts ...OptionFunc) *gobatis.DB
- type Comparable
- 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]) AndCond(cond bool, fn ...func(q *QueryCond[T])) *QueryCond[T]
- func (q *QueryCond[T]) AndEqCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndGeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndGtCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndInCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndLeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndLikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndLikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndLikeRightCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndLtCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndNeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndNotLikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndNotLikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) AndNotLikeRightCond(cond bool, column any, val any) *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]) EqCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Ge(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) GeCond(cond bool, 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]) GtCond(cond bool, 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]) InCond(cond bool, 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]) LeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Like(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeLeft(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeRight(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LikeRightCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Lt(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) LtCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) Ne(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NeCond(cond bool, 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]) NotLikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeLeft(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeRight(column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) NotLikeRightCond(cond bool, 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]) OrCond(cond bool, fn ...func(q *QueryCond[T])) *QueryCond[T]
- func (q *QueryCond[T]) OrEqCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrGeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrGtCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrInCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrLeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrLikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrLikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrLikeRightCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrLtCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrNeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrNotLikeCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrNotLikeLeftCond(cond bool, column any, val any) *QueryCond[T]
- func (q *QueryCond[T]) OrNotLikeRightCond(cond bool, column any, val any) *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
- type StreamingPage
- func NewStreamingPage[T any, V Comparable](columnName any, startValue V, limit int) *StreamingPage[T, V]
- func SelectStreamingPage[T any, V Comparable](page *StreamingPage[T, V], q *QueryCond[T], opts ...OptionFunc) (*StreamingPage[T, V], *gobatis.DB)
- func SelectStreamingPageGeneric[T any, R any, V Comparable](page *StreamingPage[R, V], q *QueryCond[T], opts ...OptionFunc) (*StreamingPage[R, V], *gobatis.DB)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteById ¶
func DeleteById[T any](id any, opts ...OptionFunc) *gobatis.DB
DeleteById 根据 ID 删除记录
func DeleteByIds ¶
func DeleteByIds[T any](ids any, opts ...OptionFunc) *gobatis.DB
DeleteByIds 根据 ID 批量删除记录
func InsertBatch ¶
func InsertBatch[T any](entities []*T, opts ...OptionFunc) *gobatis.DB
InsertBatch 批量插入多条记录
func InsertBatchSize ¶
func InsertBatchSize[T any](entities []*T, batchSize int, opts ...OptionFunc) *gobatis.DB
InsertBatchSize 批量插入多条记录
func SelectById ¶
func SelectById[T any](id any, opts ...OptionFunc) (*T, *gobatis.DB)
SelectById 根据 ID 查询单条记录
func SelectByIds ¶
func SelectByIds[T any](ids any, opts ...OptionFunc) ([]*T, *gobatis.DB)
SelectByIds 根据 ID 查询多条记录
func SelectCount ¶
SelectCount 根据条件查询记录数量
func SelectGeneric ¶
SelectGeneric 根据传入的泛型封装记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
func SelectList ¶
func SelectList[T any](q *QueryCond[T], opts ...OptionFunc) ([]*T, *gobatis.DB)
SelectList 根据条件查询多条记录
func SelectOne ¶
func SelectOne[T any](q *QueryCond[T], opts ...OptionFunc) (*T, *gobatis.DB)
SelectOne 根据条件查询单条记录
func UpdateById ¶
func UpdateById[T any](entity *T, opts ...OptionFunc) *gobatis.DB
UpdateById 根据 ID 更新,默认零值不更新
func UpdateZeroById ¶
func UpdateZeroById[T any](entity *T, opts ...OptionFunc) *gobatis.DB
UpdateZeroById 根据 ID 零值更新
Types ¶
type Comparable ¶
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
func (*Function) NotBetween ¶
type OptionFunc ¶
type OptionFunc func(*Option)
func IgnoreTotal ¶
func IgnoreTotal() OptionFunc
IgnoreTotal 分页查询忽略总数 issue: https://gitee.com/gobatis/gobatis/issues/37
type Page ¶
type Page[T any] struct { Current int `json:"current"` Size int `json:"size"` Total int64 `json:"total"` Records []*T `json:"records"` RecordsMap []T `json:"recordsMap"` }
func SelectPage ¶
SelectPage 根据条件分页查询记录
func SelectPageGeneric ¶
func SelectPageGeneric[T any, R any](page *Page[R], q *QueryCond[T], opts ...OptionFunc) (*Page[R], *gobatis.DB)
SelectPageGeneric 根据传入的泛型封装分页记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
type QueryCond ¶
type QueryCond[T any] struct { // contains filtered or unexported fields }
func NewQueryModel ¶
NewQueryModel 构建查询条件
func (*QueryCond[T]) AndLikeCond ¶
AndLikeCond 并且模糊 LIKE '%值%'
func (*QueryCond[T]) AndLikeLeftCond ¶
AndLikeLeftCond 并且左模糊 LIKE '%值'
func (*QueryCond[T]) AndLikeRightCond ¶
AndLikeRightCond 并且右模糊 LIKE '值%'
func (*QueryCond[T]) AndNotLikeCond ¶
AndNotLikeCond 并且非模糊 NOT LIKE '%值%'
func (*QueryCond[T]) AndNotLikeLeftCond ¶
AndNotLikeLeftCond 并且非左模糊 NOT LIKE '%值'
func (*QueryCond[T]) AndNotLikeRightCond ¶
AndNotLikeRightCond 并且非右模糊 NOT LIKE '值%'
func (*QueryCond[T]) LikeLeftCond ¶
LikeLeftCond 左模糊 LIKE '%值'
func (*QueryCond[T]) LikeRightCond ¶
LikeRightCond 右模糊 LIKE '值%'
func (*QueryCond[T]) NotBetween ¶
NotBetween NOT BETWEEN 值1 AND 值2
func (*QueryCond[T]) NotLikeCond ¶
NotLikeCond 非模糊 NOT LIKE '%值%'
func (*QueryCond[T]) NotLikeLeft ¶
NotLikeLeft 非左模糊 NOT LIKE '%值'
func (*QueryCond[T]) NotLikeLeftCond ¶
NotLikeLeftCond 非左模糊 NOT LIKE '%值'
func (*QueryCond[T]) NotLikeRight ¶
NotLikeRight 非右模糊 NOT LIKE '值%'
func (*QueryCond[T]) NotLikeRightCond ¶
NotLikeRightCond 非右模糊 NOT LIKE '值%'
func (*QueryCond[T]) OrLikeCond ¶
OrLikeCond 或者模糊 LIKE '%值%'
func (*QueryCond[T]) OrLikeLeftCond ¶
OrLikeLeftCond 或者左模糊 LIKE '%值'
func (*QueryCond[T]) OrLikeRightCond ¶
OrLikeRightCond 或者右模糊 LIKE '值%'
func (*QueryCond[T]) OrNotLikeCond ¶
OrNotLikeCond 或者非模糊 NOT LIKE '%值%'
func (*QueryCond[T]) OrNotLikeLeftCond ¶
OrNotLikeLeftCond 或者非左模糊 NOT LIKE '%值'
func (*QueryCond[T]) OrNotLikeRightCond ¶
OrNotLikeRightCond 或者非右模糊 NOT LIKE '值%'
func (*QueryCond[T]) OrderByAsc ¶
OrderByAsc 排序:ORDER BY 字段1,字段2 ASC
func (*QueryCond[T]) OrderByDesc ¶
OrderByDesc 排序:ORDER BY 字段1,字段2 Desc
type SqlSegment ¶
type SqlSegment interface {
// contains filtered or unexported methods
}
type StreamingPage ¶
type StreamingPage[T any, V Comparable] struct { ColumnName any `json:"columnName"` // 进行分页的列字段名称 StartValue V `json:"startValue"` // 分页起始值 Limit int `json:"limit"` // 页大小 Forward bool `json:"forward"` // 上下页翻页标识 Total int64 `json:"total"` // 总记录数 Records []*T `json:"records"` // 查询记录 RecordsMap []T `json:"recordsMap"` // 查询记录Map }
func NewStreamingPage ¶
func NewStreamingPage[T any, V Comparable](columnName any, startValue V, limit int) *StreamingPage[T, V]
func SelectStreamingPage ¶
func SelectStreamingPage[T any, V Comparable](page *StreamingPage[T, V], q *QueryCond[T], opts ...OptionFunc) (*StreamingPage[T, V], *gobatis.DB)
SelectStreamingPage 根据条件分页查询记录
func SelectStreamingPageGeneric ¶
func SelectStreamingPageGeneric[T any, R any, V Comparable](page *StreamingPage[R, V], q *QueryCond[T], opts ...OptionFunc) (*StreamingPage[R, V], *gobatis.DB)
SelectStreamingPageGeneric 根据传入的泛型封装分页记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体