Documentation
¶
Index ¶
- func MongoDB() *mongo.Database
- type Crud
- type Mongo
- func (m *Mongo) Create() Crud
- func (m *Mongo) CreateMore() Crud
- func (m *Mongo) CursorScan(cur *mongo.Cursor, data interface{})
- func (m *Mongo) DB() *mongo.Database
- func (m *Mongo) Delete(id interface{}) Crud
- func (m *Mongo) Error() error
- func (m *Mongo) Get(params cmap.CMap) Crud
- func (m *Mongo) GetByDataSearch(params cmap.CMap) (cur *mongo.Cursor, err error)
- func (m *Mongo) GetByID(id interface{}) Crud
- func (m *Mongo) GetBySearch(params cmap.CMap) Crud
- func (m *Mongo) Init(param *Params)
- func (m *Mongo) Pager() result.Pager
- func (m *Mongo) Params(params ...Param) Crud
- func (m *Mongo) RowsAffected() int64
- func (m *Mongo) Update() Crud
- type Param
- type Params
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Crud ¶ added in v1.30.0
type Crud interface {
// init crud
Init(param *Params)
// DB
DB() *mongo.Database
// new/replace param
// return param
Params(param ...Param) Crud
// get url params
// like form data
GetBySearch(params cmap.CMap) Crud // search single table
Get(params cmap.CMap) Crud // get data no search
GetByID(id interface{}) Crud // by id
// delete by id/ids
Delete(id interface{}) Crud // delete
// crud and search id
// json data
Update() Crud // update
Create() Crud // create, include res insert id
CreateMore() Crud // create more, data must array type, single table
// select
Error() error // crud error
RowsAffected() int64 // inflect rows
Pager() result.Pager // search pager
}
Crud
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
implement Crud
func (*Mongo) CursorScan ¶
scan data to mongo data
func (*Mongo) GetByDataSearch ¶
func (*Mongo) RowsAffected ¶
type Params ¶
type Params struct {
// attributes
InnerTable []string // inner join tables
LeftTable []string // left join tables
Table string // table name
Model interface{} // table model, like User{}
KeyModel interface{} // key like model
Data interface{} // table model data, like var user User{}, it is 'user', it store real data
// count
SubSQL string // SubQuery SQL
// where
WhereSQL string // SubWhere SQL
}
crud params
Click to show internal directories.
Click to hide internal directories.