Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(ctx context.Context, dbx *sqlx.DB, record DeleteRecord) (int64, error)
- func Get[T any](ctx context.Context, dbx *sqlx.DB, record GetRecord, opts ...SelectOption) (*T, error)
- func GetMap(ctx context.Context, dbx *sqlx.DB, record GetRecord, opts ...SelectOption) (map[string]any, error)
- func Insert(ctx context.Context, dbx *sqlx.DB, record InsertRecord, opts ...InsertOption) (int64, error)
- func Update(ctx context.Context, dbx *sqlx.DB, record UpdateRecord, opts ...UpdateOption) (int64, error)
- func UseDefaultMasterDB(master *sqlx.DB)
- func UseDefaultReadDB(read *sqlx.DB)
- type Condition
- type ConditionType
- type Dao
- func (dao *Dao) BatchReplaceInto(models any, omitColumns ...string) (int64, error)
- func (dao *Dao) BatchReplaceIntoContext(ctx context.Context, models any, omitColumns ...string) (int64, error)
- func (dao *Dao) BatchSave(models any, omitColumns ...string) (int64, error)
- func (dao *Dao) BatchSaveContext(ctx context.Context, models any, omitColumns ...string) (int64, error)
- func (dao *Dao) DBColumns(omitColumns ...string) []string
- func (dao *Dao) DeleteByColumn(kv *KV) (int64, error)
- func (dao *Dao) DeleteByColumnContext(ctx context.Context, kv *KV) (int64, error)
- func (dao *Dao) DeleteByColumnTx(tx *sqlx.Tx, kv *KV) (int64, error)
- func (dao *Dao) DeleteByColumnTxContext(ctx context.Context, tx *sqlx.Tx, kv *KV) (int64, error)
- func (dao *Dao) DeleteByColumns(kvs *MultiKV) (int64, error)
- func (dao *Dao) DeleteByColumnsContext(ctx context.Context, kvs *MultiKV) (int64, error)
- func (dao *Dao) DeleteByColumnsTx(tx *sqlx.Tx, kvs *MultiKV) (int64, error)
- func (dao *Dao) DeleteByColumnsTxContext(ctx context.Context, tx *sqlx.Tx, kvs *MultiKV) (int64, error)
- func (dao *Dao) DeleteByCond(where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) DeleteByCondContext(ctx context.Context, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) DeleteByCondTx(tx *sqlx.Tx, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) DeleteByCondTxContext(ctx context.Context, tx *sqlx.Tx, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) DeleteByID(id any) (bool, error)
- func (dao *Dao) DeleteByIDContext(ctx context.Context, id any) (bool, error)
- func (dao *Dao) DeleteByIDTx(tx *sqlx.Tx, id any) (bool, error)
- func (dao *Dao) DeleteByIDTxContext(ctx context.Context, tx *sqlx.Tx, id any) (bool, error)
- func (dao *Dao) Get(dest any, selector *sqlbuilder.Selector) (bool, error)
- func (dao *Dao) GetByColumn(kv *KV, dest Model) (bool, error)
- func (dao *Dao) GetByColumnContext(ctx context.Context, kv *KV, dest Model) (bool, error)
- func (dao *Dao) GetByColumnTx(tx *sqlx.Tx, kv *KV, dest Model) (bool, error)
- func (dao *Dao) GetByColumnTxContext(ctx context.Context, tx *sqlx.Tx, kv *KV, dest Model) (bool, error)
- func (dao *Dao) GetByID(id any, dest Model) (bool, error)
- func (dao *Dao) GetByIDContext(ctx context.Context, id any, dest Model) (bool, error)
- func (dao *Dao) GetColumnsByModel(model any, omitColumns ...string) []string
- func (dao *Dao) GetColumnsByType(typ reflect.Type, omitColumns ...string) []string
- func (dao *Dao) GetContext(ctx context.Context, dest any, selector *sqlbuilder.Selector) (bool, error)
- func (dao *Dao) GetMasterDB() *sqlx.DB
- func (dao *Dao) GetReadDB() *sqlx.DB
- func (dao *Dao) GetTx(tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) (bool, error)
- func (dao *Dao) GetTxContext(ctx context.Context, tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) (bool, error)
- func (dao *Dao) IgnoreInto(dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) IgnoreIntoContext(ctx context.Context, dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) List(kv *KV, dest any) error
- func (dao *Dao) ListByColumns(kvs *MultiKV, dest any) error
- func (dao *Dao) ListByColumnsContext(ctx context.Context, kvs *MultiKV, dest any) error
- func (dao *Dao) ListByColumnsTx(tx *sqlx.Tx, kvs *MultiKV, dest any) error
- func (dao *Dao) ListByColumnsTxContext(ctx context.Context, tx *sqlx.Tx, kvs *MultiKV, dest any) error
- func (dao *Dao) ListByIDs(dest any, ids ...any) error
- func (dao *Dao) ListByIDsContext(ctx context.Context, dest any, ids ...any) error
- func (dao *Dao) ListByIDsTx(tx *sqlx.Tx, dest any, ids ...any) error
- func (dao *Dao) ListByIDsTxContext(ctx context.Context, tx *sqlx.Tx, dest any, ids ...any) error
- func (dao *Dao) ListContext(ctx context.Context, kv *KV, dest any) error
- func (dao *Dao) ListTx(tx *sqlx.Tx, kv *KV, dest any) error
- func (dao *Dao) ListTxContext(ctx context.Context, tx *sqlx.Tx, kv *KV, dest any) error
- func (dao *Dao) ReplaceInto(dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) ReplaceIntoContext(ctx context.Context, dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) SQLBuilder() *sqlbuilder.Builder
- func (dao *Dao) Save(dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) SaveContext(ctx context.Context, dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) SaveTx(tx *sqlx.Tx, dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) SaveTxContext(ctx context.Context, tx *sqlx.Tx, dest Model, omitColumns ...string) (int64, error)
- func (dao *Dao) Select(dest any, selector *sqlbuilder.Selector) error
- func (dao *Dao) SelectContext(ctx context.Context, dest any, selector *sqlbuilder.Selector) error
- func (dao *Dao) SelectTx(tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) error
- func (dao *Dao) SelectTxContext(ctx context.Context, tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) error
- func (dao *Dao) Selector(columns ...string) *sqlbuilder.Selector
- func (dao *Dao) TableName() string
- func (dao *Dao) Update(m Model, omitColumns ...string) (bool, error)
- func (dao *Dao) UpdateByCond(attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) UpdateByCondContext(ctx context.Context, attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) UpdateByCondTx(tx *sqlx.Tx, attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
- func (dao *Dao) UpdateByCondTxContext(ctx context.Context, tx *sqlx.Tx, attr map[string]any, ...) (int64, error)
- func (dao *Dao) UpdateContext(ctx context.Context, m Model, omitColumns ...string) (bool, error)
- func (dao *Dao) UpdateField(idValue any, fieldMap map[string]any) (bool, error)
- func (dao *Dao) UpdateFieldContext(ctx context.Context, idValue any, fieldMap map[string]any) (bool, error)
- func (dao *Dao) UpdateFieldTx(tx *sqlx.Tx, idValue any, fieldMap map[string]any) (bool, error)
- func (dao *Dao) UpdateFieldTxContext(ctx context.Context, tx *sqlx.Tx, idValue any, fieldMap map[string]any) (bool, error)
- func (dao *Dao) UpdateTx(tx *sqlx.Tx, m Model, omitColumns ...string) (bool, error)
- func (dao *Dao) UpdateTxContext(ctx context.Context, tx *sqlx.Tx, m Model, omitColumns ...string) (bool, error)
- func (dao *Dao) With(master, read *sqlx.DB, opts ...Option) *Dao
- type DataWrapper
- type DeleteRecord
- type FieldsFilter
- type GetRecord
- type InsertOption
- type InsertOptions
- type InsertRecord
- type KV
- type Model
- type MultiKV
- type Op
- type Option
- type OrderField
- type OrderType
- type Page
- type QueryRecord
- type SelectOption
- type SelectOptions
- type TableMeta
- type TxFun
- type TxManager
- type UpdateOption
- type UpdateOptions
- type UpdateRecord
Constants ¶
const ( OpAnd Op = "and" OpOr Op = "or" ConditionTypeEq ConditionType = "eq" // 等于 ConditionTypeNotEq ConditionType = "not_eq" // 不等于 ConditionTypeLike ConditionType = "like" // 模糊匹配 ConditionTypeNotLike ConditionType = "not_like" // 不包含 ConditionTypeIn ConditionType = "in" // in ConditionTypeNotIn ConditionType = "not_in" // not in ConditionTypeGt ConditionType = "gt" // 大于 ConditionTypeLt ConditionType = "lt" // 小于 ConditionTypeGte ConditionType = "gte" // 大于等于 ConditionTypeLte ConditionType = "lte" // 小于等于 OrderTypeAsc OrderType = "asc" // 升序 OrderTypeDesc OrderType = "desc" // 降序 )
Variables ¶
var ( ErrUpdatePrimaryKeyRequire = errors.New("[daox] Primary key require for update") ErrTxNil = errors.New("[daox] Tx is nil") )
Functions ¶
func Get ¶
func Get[T any](ctx context.Context, dbx *sqlx.DB, record GetRecord, opts ...SelectOption) (*T, error)
Get 查询单条记录
func GetMap ¶
func GetMap(ctx context.Context, dbx *sqlx.DB, record GetRecord, opts ...SelectOption) (map[string]any, error)
GetMap 查询单条记录,返回 map
func Insert ¶
func Insert(ctx context.Context, dbx *sqlx.DB, record InsertRecord, opts ...InsertOption) (int64, error)
Insert 通用 insert 操作
func Update ¶
func Update(ctx context.Context, dbx *sqlx.DB, record UpdateRecord, opts ...UpdateOption) (int64, error)
Update 通用 update 操作
func UseDefaultMasterDB ¶
func UseDefaultReadDB ¶
Types ¶
type Condition ¶
type Condition struct { Disable bool `json:"disable"` // true 禁用该条件 Op Op `json:"op"` // and or 连接符 Field string `json:"field"` // 查询条件字段 Vals []any `json:"vals"` // 查询字段值 ConditionType ConditionType `json:"condition_type"` // 查找类型 }
Condition 条件语句
type ConditionType ¶
type ConditionType string
type Dao ¶
type Dao struct { Mapper *reflectx.Mapper TableMeta TableMeta // contains filtered or unexported fields }
func CreateDAO ¶
CreateDAO 函数用于创建一个新的Dao对象 tableName 参数表示表名 primaryKey 参数表示主键 structType 参数表示数据结构类型 opts 参数表示可选的选项 返回值为创建的Dao对象指针
func NewDAO ¶
func NewDAO(master *sqlx.DB, tableName string, primaryKey string, structType reflect.Type, opts ...Option) *Dao
NewDAO 函数用于创建一个新的Dao对象 master 参数用于连接数据库 tableName 参数表示表名 primaryKey 参数表示主键 structType 参数表示数据结构类型 opts 参数表示可选的选项 返回值为创建的Dao对象指针
func (*Dao) BatchReplaceInto ¶
BatchReplaceInto 批量新增,使用 replace into 方式 models 是一个 slice omitColumns 不需要 insert 的字段
func (*Dao) BatchReplaceIntoContext ¶
func (dao *Dao) BatchReplaceIntoContext(ctx context.Context, models any, omitColumns ...string) (int64, error)
BatchReplaceIntoContext 批量新增,使用 replace into 方式,携带上下文 models 是一个 slice omitColumns 不需要 insert 的字段
func (*Dao) BatchSaveContext ¶
func (dao *Dao) BatchSaveContext(ctx context.Context, models any, omitColumns ...string) (int64, error)
BatchSaveContext 批量新增 omitColumns 不需要 insert 的字段
func (*Dao) DeleteByColumn ¶
DeleteByColumn 按字段名删除
func (*Dao) DeleteByColumnContext ¶
DeleteByColumnContext 按字段名删除,携带上下文
func (*Dao) DeleteByColumnTx ¶
DeleteByColumnTx 按字段名删除,支持事务
func (*Dao) DeleteByColumnTxContext ¶
DeleteByColumnTxContext 按字段名删除,支持事务,携带上下文
func (*Dao) DeleteByColumns ¶
DeleteByColumns 指定字段删除多个值
func (*Dao) DeleteByColumnsContext ¶
DeleteByColumnsContext 指定字段删除多个值,携带上下文
func (*Dao) DeleteByColumnsTx ¶
DeleteByColumnsTx 指定字段多个值删除
func (*Dao) DeleteByColumnsTxContext ¶
func (dao *Dao) DeleteByColumnsTxContext(ctx context.Context, tx *sqlx.Tx, kvs *MultiKV) (int64, error)
DeleteByColumnsTxContext 指定字段多个值删除,携带上下文
func (*Dao) DeleteByCond ¶
func (dao *Dao) DeleteByCond(where sqlbuilder.ConditionBuilder) (int64, error)
DeleteByCond 根据where条件删除
func (*Dao) DeleteByCondContext ¶
func (dao *Dao) DeleteByCondContext(ctx context.Context, where sqlbuilder.ConditionBuilder) (int64, error)
DeleteByCondContext 根据where条件删除,携带上下文
func (*Dao) DeleteByCondTx ¶
func (dao *Dao) DeleteByCondTx(tx *sqlx.Tx, where sqlbuilder.ConditionBuilder) (int64, error)
DeleteByCondTx 根据where条件删除,支持事务
func (*Dao) DeleteByCondTxContext ¶
func (dao *Dao) DeleteByCondTxContext(ctx context.Context, tx *sqlx.Tx, where sqlbuilder.ConditionBuilder) (int64, error)
DeleteByCondTxContext 根据where条件删除,支持事务,携带上下文
func (*Dao) DeleteByIDContext ¶
DeleteByIDContext 根据id删除数据,携带上下文
func (*Dao) DeleteByIDTx ¶
DeleteByIDTx 根据id删除数据,支持事务
func (*Dao) DeleteByIDTxContext ¶
DeleteByIDTxContext 根据id删除数据,支持事务,携带上下文
func (*Dao) GetByColumn ¶
GetByColumn 按指定字段查询单条数据 bool 数据是否存在
func (*Dao) GetByColumnContext ¶
GetByColumnContext 按指定字段查询单条数据,携带上下文 bool 数据是否存在
func (*Dao) GetByColumnTx ¶
GetByColumnTx 按指定字段查询单条数据,支持事务 bool 数据是否存在
func (*Dao) GetByColumnTxContext ¶
func (dao *Dao) GetByColumnTxContext(ctx context.Context, tx *sqlx.Tx, kv *KV, dest Model) (bool, error)
GetByColumnTxContext 按指定字段查询单条数据,支持事务,携带上下文 bool 数据是否存在
func (*Dao) GetByIDContext ¶
GetByIDContext 根据 id 查询单条数据,携带上下文
func (*Dao) GetColumnsByModel ¶
GetColumnsByModel 根据 model 结构获取数据库字段 omitColumns 表示需要忽略的字段
func (*Dao) GetColumnsByType ¶
GetColumnsByType 通过字段 tag 解析数据库字段
func (*Dao) GetContext ¶
func (*Dao) GetMasterDB ¶
func (*Dao) GetTxContext ¶
func (dao *Dao) GetTxContext(ctx context.Context, tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) (bool, error)
GetTxContext 根据查询条件查询单条记录,支持事务,携带上下文 dest 必须是一个指针
func (*Dao) IgnoreInto ¶
IgnoreInto 使用 INSERT IGNORE INTO 如果记录已存在则忽略 omitColumns 不需要 insert 的字段
func (*Dao) IgnoreIntoContext ¶
func (dao *Dao) IgnoreIntoContext(ctx context.Context, dest Model, omitColumns ...string) (int64, error)
IgnoreIntoContext 使用 INSERT IGNORE INTO 如果记录已存在则忽略,携带上下文 omitColumns 不需要 insert 的字段
func (*Dao) ListByColumns ¶
ListByColumns 指定字段多个值查询多条数据 dest: slice pointer
func (*Dao) ListByColumnsContext ¶
ListByColumnsContext 指定字段多个值查询多条数据,携带上下文 dest: slice pointer
func (*Dao) ListByColumnsTx ¶
ListByColumnsTx 指定字段多个值查询多条数据,支持事务
func (*Dao) ListByColumnsTxContext ¶
func (dao *Dao) ListByColumnsTxContext(ctx context.Context, tx *sqlx.Tx, kvs *MultiKV, dest any) error
ListByColumnsTxContext 指定字段多个值查询多条数据,支持事务,携带上下文
func (*Dao) ListByIDsContext ¶
ListByIDsContext 根据 id 查询多条数据,携带上下文
func (*Dao) ListByIDsTx ¶
ListByIDsTx 查询多个id值,支持事务
func (*Dao) ListByIDsTxContext ¶
ListByIDsTxContext 查询多个id值,支持事务,携带上下文
func (*Dao) ListContext ¶
ListContext 指定字段查询多条数据,携带上下文
func (*Dao) ListTxContext ¶
ListTxContext 指定字段查询多条数据,支持事务,携带上下文
func (*Dao) ReplaceInto ¶
ReplaceInto replace into table omitColumns 不需要 insert 的字段
func (*Dao) ReplaceIntoContext ¶
func (dao *Dao) ReplaceIntoContext(ctx context.Context, dest Model, omitColumns ...string) (int64, error)
ReplaceIntoContext replace into table,携带上下文 omitColumns 不需要 insert 的字段
func (*Dao) SQLBuilder ¶
func (dao *Dao) SQLBuilder() *sqlbuilder.Builder
SQLBuilder 创建当前表的 sqlbuilder
func (*Dao) SaveContext ¶
SaveContext 插入数据,携带上下文 omitColumns 不需要 insert 的字段
func (*Dao) SaveTxContext ¶
func (dao *Dao) SaveTxContext(ctx context.Context, tx *sqlx.Tx, dest Model, omitColumns ...string) (int64, error)
SaveTxContext 插入数据,支持事务,携带上下文 omitColumns 不需要 insert 的字段
func (*Dao) Select ¶
func (dao *Dao) Select(dest any, selector *sqlbuilder.Selector) error
Select 根据查询条件查询列表 dest 必须是一个 slice 指针
func (*Dao) SelectContext ¶
SelectContext 根据查询条件查询列表,携带上下文 dest 必须是一个 slice 指针
func (*Dao) SelectTxContext ¶
func (dao *Dao) SelectTxContext(ctx context.Context, tx *sqlx.Tx, dest any, selector *sqlbuilder.Selector) error
SelectTxContext 根据查询条件查询列表,携带上下文 dest 必须是一个 slice 指针
func (*Dao) Selector ¶
func (dao *Dao) Selector(columns ...string) *sqlbuilder.Selector
Selector 创建当前表的 selector columns 是查询指定字段,为空则是全部字段
func (*Dao) UpdateByCond ¶
func (dao *Dao) UpdateByCond(attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
UpdateByCond 根据条件更新字段 attr 字段更新值
func (*Dao) UpdateByCondContext ¶
func (dao *Dao) UpdateByCondContext(ctx context.Context, attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
UpdateByCondContext 根据条件更新字段,携带上下文 attr 字段更新值
func (*Dao) UpdateByCondTx ¶
func (dao *Dao) UpdateByCondTx(tx *sqlx.Tx, attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
UpdateByCondTx 根据条件更新字段,支持事务
func (*Dao) UpdateByCondTxContext ¶
func (dao *Dao) UpdateByCondTxContext(ctx context.Context, tx *sqlx.Tx, attr map[string]any, where sqlbuilder.ConditionBuilder) (int64, error)
UpdateByCondTxContext 根据条件更新字段,支持事务,携带上下文
func (*Dao) UpdateContext ¶
UpdateContext 全字段更新,携带上下文
func (*Dao) UpdateField ¶
UpdateField 部分字段更新
func (*Dao) UpdateFieldContext ¶
func (dao *Dao) UpdateFieldContext(ctx context.Context, idValue any, fieldMap map[string]any) (bool, error)
UpdateFieldContext 部分字段更新,携带上下文
func (*Dao) UpdateFieldTx ¶
UpdateFieldTx 部分字段更新,支持事务
func (*Dao) UpdateFieldTxContext ¶
func (dao *Dao) UpdateFieldTxContext(ctx context.Context, tx *sqlx.Tx, idValue any, fieldMap map[string]any) (bool, error)
UpdateFieldTxContext 部分字段更新,支持事务,携带上下文
type DeleteRecord ¶
type DeleteRecord struct { TableName string `json:"table_name"` // 表名 Conditions []Condition `json:"conditions"` // 条件字段 }
DeleteRecord 删除记录
type FieldsFilter ¶
type GetRecord ¶
type GetRecord struct { TableName string `json:"table_name"` // 查询表 Fields []string `json:"fields"` // 投影字段 Conditions []Condition `json:"conditions,omitempty"` // 查找字段 }
GetRecord 单条记录查询
type InsertOption ¶
type InsertOption func(*InsertOptions)
func WithInsertDataWrapper ¶
func WithInsertDataWrapper(dataWrapper DataWrapper[map[string]any, map[string]any]) InsertOption
WithInsertDataWrapper 数据转换
func WithInsertFieldsFilter ¶
func WithInsertFieldsFilter(fieldsFilter FieldsFilter) InsertOption
WithInsertFieldsFilter 过滤 insert 字段
type InsertOptions ¶
type InsertOptions struct { DataWrapper DataWrapper[map[string]any, map[string]any] FieldsFilter FieldsFilter }
type InsertRecord ¶
type InsertRecord struct { TableName string `json:"table_name"` // 表名 Row map[string]any `json:"row"` // 行数据 }
InsertRecord 插入记录
type OrderField ¶
OrderField 排序字段
type Page ¶
type Page struct { Offset int64 `json:"offset"` // 游标起始位置 Limit int64 `json:"limit"` // 每页记录数 HasNext bool `json:"has_next"` // 是否有下一页 Count int64 `json:"count"` // 总记录数 QueryCount bool `json:"query_count"` // 是否查询总数 }
Page 分页参数
func Find ¶
func Find[T any](ctx context.Context, dbx *sqlx.DB, query QueryRecord, opts ...SelectOption) (list []T, page *Page, err error)
Find 通用查询封装
func FindListMap ¶
func FindListMap(ctx context.Context, dbx *sqlx.DB, query QueryRecord, opts ...SelectOption) (list []map[string]any, page *Page, err error)
FindListMap 通用查询封装,返回 map 类型
type QueryRecord ¶
type QueryRecord struct { TableName string `json:"table_name"` // 查询表 Fields []string `json:"fields"` // 投影字段 Conditions []Condition `json:"conditions,omitempty"` // 查找字段 OrderFields []OrderField `json:"order_fields,omitempty"` // 排序字段 Page *Page `json:"page,omitempty"` // 分页参数 }
QueryRecord 查询参数
func (QueryRecord) ToCountSQLArgs ¶
func (q QueryRecord) ToCountSQLArgs() (sql string, args []any, err error)
ToCountSQLArgs 返回 count 查询 sql 语句和参数
type SelectOption ¶
type SelectOption func(*SelectOptions)
func WithSelectDataWrapper ¶
func WithSelectDataWrapper(resultWrapper DataWrapper[any, any]) SelectOption
WithSelectDataWrapper 返回结果转换
func WithSelectFieldsFilter ¶
func WithSelectFieldsFilter(fieldsFilter FieldsFilter) SelectOption
WithSelectFieldsFilter 过滤 select 字段
type SelectOptions ¶
type SelectOptions struct { FieldsFilter FieldsFilter ResultWrapper DataWrapper[any, any] }
type TableMeta ¶
type TableMeta struct { TableName string StructType reflect.Type Columns []string PrimaryKey string IsAutoIncrement bool }
func (*TableMeta) OmitColumns ¶
OmitColumns 数据库表字段 omit 包含的字段
type TxManager ¶
type TxManager struct {
// contains filtered or unexported fields
}
TxManager 事务管理器
type UpdateOption ¶
type UpdateOption func(*UpdateOptions)
func WithUpdateDataWrapper ¶
func WithUpdateDataWrapper(dataWrapper DataWrapper[map[string]any, map[string]any]) UpdateOption
WithUpdateDataWrapper 数据转换
func WithUpdateFieldsFilter ¶
func WithUpdateFieldsFilter(fieldsFilter FieldsFilter) UpdateOption
WithUpdateFieldsFilter 过滤 update 字段
type UpdateOptions ¶
type UpdateOptions struct { DataWrapper DataWrapper[map[string]any, map[string]any] FieldsFilter FieldsFilter }