Documentation ¶
Index ¶
- Constants
- Variables
- func Delete[T Filter](m *Model, filter T, fn ...func(*CondOptions) error) (int64, error)
- func DeleteMany[T Filter](m *Model, filter T, fn ...func(*CondOptions) error) (int64, error)
- func Find[T Filter](m *Model, filter T, fn ...func(*CondOptions) error) (ztype.Maps, error)
- func FindCol[T Filter](m *Model, field string, filter T, fn ...func(*CondOptions) error) (ztype.Type, bool, error)
- func FindCols[T Filter](m *Model, field string, filter T, fn ...func(*CondOptions) error) (ztype.SliceType, error)
- func FindOne[T Filter](m *Model, filter T, fn ...func(*CondOptions) error) (ztype.Map, error)
- func Insert(m *Model, data ztype.Map) (lastId interface{}, err error)
- func InsertMany(m *Model, datas ztype.Maps) (lastIds []interface{}, err error)
- func Update[T Filter](m *Model, filter T, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func UpdateMany[T Filter](m *Model, filter T, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func Upload(c *znet.Context, o ...func(options *UploadOptions)) (files []string, err error)
- func VerifiData(data ztype.Map, columns define.Fields, active activeType) (ztype.Map, error)
- type ColumnEnum
- type CondOptions
- type CryptProcess
- type DataTime
- type DealOldColumn
- type Filter
- type Migration
- type Migrationer
- type Model
- func (m *Model) Alias() string
- func (m *Model) DI() zdi.Injector
- func (m *Model) DeCrypt(row ztype.Map) (err error)
- func (m *Model) DeCryptID(nid string) (id string, err error)
- func (m *Model) Define() define.Define
- func (m *Model) EnCrypt(row *ztype.Map) (err error)
- func (m *Model) EnCryptID(id string) (nid string, err error)
- func (m *Model) GetAfterProcess(p []string) (fn []afterProcess, err error)
- func (m *Model) GetBeforeProcess(p []string) (fn []beforeProcess, err error)
- func (m *Model) GetCryptProcess(cryptName string) (fn CryptProcess, err error)
- func (m *Model) GetField(name string) (define.Field, bool)
- func (m *Model) GetFields(exclude ...string) []string
- func (m *Model) GetModelFields() define.Fields
- func (m *Model) GetViewFields(view string) []string
- func (m *Model) GetViews() ztype.Map
- func (m *Model) Migration() Migrationer
- func (m *Model) Name() string
- func (m *Model) Operation() *Operation
- func (m *Model) TableName() string
- type Models
- func (ms *Models) BatchReg(models map[string]define.Define, force bool) error
- func (ms *Models) ForEach(fn func(key string, m *Model) bool)
- func (ms *Models) Get(alias string) (*Model, bool)
- func (ms *Models) Reg(name string, data define.Define, force bool) (*Model, error)
- func (ms *Models) Storage() Storageer
- type Module
- type Operation
- func (o *Operation) Count(filter ztype.Map) (int64, error)
- func (o *Operation) DeCryptID(nid string) (id string, err error)
- func (o *Operation) Delete(id any, filter ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func (o *Operation) DeleteByID(id any, fn ...func(*CondOptions) error) (total int64, err error)
- func (o *Operation) DeleteMany(id any, filter ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func (o *Operation) EnCryptID(id string) (nid string, err error)
- func (o *Operation) Exists(filter ztype.Map) (bool, error)
- func (o *Operation) Find(filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Maps, error)
- func (o *Operation) FindCols(field string, filter ztype.Map) (ztype.SliceType, error)
- func (o *Operation) FindOne(filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Map, error)
- func (o *Operation) FindOneByID(id any, fn ...func(*CondOptions) error) (ztype.Map, error)
- func (o *Operation) Insert(data ztype.Map) (lastId interface{}, err error)
- func (o *Operation) InsertMany(data ztype.Maps) (lastId interface{}, err error)
- func (o *Operation) Pages(page, pagesize int, filter ztype.Map, fn ...func(*CondOptions) error) (*PageData, error)
- func (o *Operation) Update(filter ztype.Map, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func (o *Operation) UpdateByID(id any, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- func (o *Operation) UpdateMany(filter ztype.Map, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
- type Operations
- type Options
- type PageData
- type PageInfo
- type SQL
- func (s *SQL) Delete(table string, filter ztype.Map, fn ...func(*CondOptions) error) (int64, error)
- func (s *SQL) Find(table string, filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Maps, error)
- func (s *SQL) First(table string, filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Map, error)
- func (s *SQL) GetStorageType() StorageType
- func (s *SQL) Insert(table string, data ztype.Map) (lastId interface{}, err error)
- func (s *SQL) InsertMany(table string, data ztype.Maps) (lastIds []interface{}, err error)
- func (s *SQL) Migration(model *Model) Migrationer
- func (s *SQL) Pages(table string, page, pagesize int, filter ztype.Map, ...) (ztype.Maps, PageInfo, error)
- func (s *SQL) Update(table string, data ztype.Map, filter ztype.Map, fn ...func(*CondOptions) error) (int64, error)
- type SQLOptions
- type StorageJoin
- type StorageModelOptions
- type StorageType
- type Storageer
- type UploadOptions
- type ValidTriggerType
Constants ¶
View Source
const ( IDKey = "_id" CreatedAtKey = "created_at" // CreatedByKey = "created_by" UpdatedAtKey = "updated_at" DeletedAtKey = "deleted_at" )
Variables ¶
View Source
var Common = &common{}
View Source
var Inside = &inside{}
Functions ¶
func DeleteMany ¶
func UpdateMany ¶
Types ¶
type ColumnEnum ¶
type CondOptions ¶
type CryptProcess ¶
type DealOldColumn ¶
type DealOldColumn uint8
const ( DealOldColumnNone DealOldColumn = iota DealOldColumnDelete DealOldColumnRename )
type Migration ¶
func (*Migration) Auto ¶
func (m *Migration) Auto(oldColumn DealOldColumn) (err error)
func (*Migration) CreateTable ¶
func (*Migration) UpdateTable ¶
func (m *Migration) UpdateTable(oldColumn DealOldColumn) error
type Migrationer ¶
type Migrationer interface { Auto(deleteColumn DealOldColumn) (err error) HasTable() bool }
type Model ¶
type Model struct { Storage Storageer Hashid *hashid.HashID `json:"-"` JSONPath string JSON []byte Fields []string `json:"-"` StorageType StorageType // contains filtered or unexported fields }
func (*Model) GetAfterProcess ¶
func (*Model) GetBeforeProcess ¶
func (*Model) GetCryptProcess ¶
func (m *Model) GetCryptProcess(cryptName string) (fn CryptProcess, err error)
func (*Model) GetModelFields ¶
func (*Model) GetViewFields ¶
func (*Model) Migration ¶
func (m *Model) Migration() Migrationer
type Models ¶
type Models struct {
// contains filtered or unexported fields
}
type Module ¶
type Module struct { service.ModuleLifeCycle // Operations *Operations // Models *Models Options Options }
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
func (*Operation) Delete ¶
func (o *Operation) Delete(id any, filter ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
Delete 删除数据
func (*Operation) DeleteByID ¶
DeleteByID 通过ID删除数据
func (*Operation) DeleteMany ¶
func (o *Operation) DeleteMany(id any, filter ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
DeleteMany 删除多条数据
func (*Operation) FindOneByID ¶
FindOneByID 通过ID查询
func (*Operation) InsertMany ¶
InsertMany 批量插入数据
func (*Operation) Pages ¶
func (o *Operation) Pages(page, pagesize int, filter ztype.Map, fn ...func(*CondOptions) error) (*PageData, error)
Pages 分页查询
func (*Operation) Update ¶
func (o *Operation) Update(filter ztype.Map, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
Update 更新数据
func (*Operation) UpdateByID ¶
func (o *Operation) UpdateByID(id any, data ztype.Map, fn ...func(*CondOptions) error) (total int64, err error)
UpdateByID 通过ID更新
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
type SQL ¶
type SQL struct { Options SQLOptions // contains filtered or unexported fields }
func (*SQL) GetStorageType ¶
func (s *SQL) GetStorageType() StorageType
func (*SQL) InsertMany ¶
func (*SQL) Migration ¶
func (s *SQL) Migration(model *Model) Migrationer
type SQLOptions ¶
type SQLOptions struct {
Prefix string
}
type StorageJoin ¶
type StorageJoin struct { Table string As string Expr string ModelOptions builder.JoinOption }
type StorageModelOptions ¶
type StorageModelOptions struct { }
type Storageer ¶
type Storageer interface { GetStorageType() StorageType Find(table string, filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Maps, error) First(table string, filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Map, error) Pages(table string, page, pagesize int, filter ztype.Map, fn ...func(*CondOptions) error) (ztype.Maps, PageInfo, error) Migration(model *Model) Migrationer Insert(table string, data ztype.Map) (lastId interface{}, err error) InsertMany(table string, data ztype.Maps) (lastIds []interface{}, err error) Delete(table string, filter ztype.Map, fn ...func(*CondOptions) error) (int64, error) Update(table string, data ztype.Map, filter ztype.Map, fn ...func(*CondOptions) error) (int64, error) }
type UploadOptions ¶
type ValidTriggerType ¶
type ValidTriggerType uint
const ( ValidTriggerAll ValidTriggerType = iota ValidTriggerCreate ValidTriggerUpdate )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.