mongo

package
v1.20.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MongoDB

func MongoDB() *mongo.Database

single db

Types

type Mongo

type Mongo struct {
	// contains filtered or unexported fields
}

implement Crud

func NewCrud

func NewCrud(params ...Param) (crud *Mongo)

new crud

func (*Mongo) Create

func (m *Mongo) Create() *Mongo

create

func (*Mongo) CreateMore

func (m *Mongo) CreateMore() *Mongo

create more

func (*Mongo) CursorScan

func (m *Mongo) CursorScan(cur *mongo.Cursor, data interface{})

scan data to mongo data

func (*Mongo) Delete

func (m *Mongo) Delete(id interface{}) *Mongo

delete

func (*Mongo) Error

func (m *Mongo) Error() error

func (*Mongo) GetByData

func (m *Mongo) GetByData(params cmap.CMap) *Mongo

func (*Mongo) GetByDataSearch

func (m *Mongo) GetByDataSearch(params cmap.CMap) (cur *mongo.Cursor, err error)

func (*Mongo) GetByID

func (m *Mongo) GetByID(id interface{}) *Mongo

must be mongodb primitive.ObjectID by id

func (*Mongo) GetBySearch

func (m *Mongo) GetBySearch(params cmap.CMap) *Mongo

search pager info

func (*Mongo) Init

func (m *Mongo) Init(param *Params)

func (*Mongo) Pager

func (m *Mongo) Pager() result.Pager

func (*Mongo) Params

func (m *Mongo) Params(params ...Param) *Mongo

func (*Mongo) RowsAffected

func (m *Mongo) RowsAffected() int64

func (*Mongo) Select

func (m *Mongo) Select(q interface{}, args ...interface{}) *Mongo

create

func (*Mongo) Single

func (m *Mongo) Single() *Mongo

func (*Mongo) Update

func (m *Mongo) Update() *Mongo

update must id string

type Param

type Param func(*Params)

func Data

func Data(Data interface{}) Param

func KeyModel

func KeyModel(KeyModel interface{}) Param

func Model

func Model(Model interface{}) Param

func Table

func Table(Table string) Param

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL