mongodb

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WhereIs = iota
	WhereNot
	WhereGt
	WhereLt
	WhereOr
	OrderAsc
	OrderDesc
)

Variables

This section is empty.

Functions

func Init

func Init() (orm.ORM, error)

Types

type DBConn

type DBConn struct {
	Database string //连接的数据库

	*mongo.Client
}
var ORMConn *DBConn

func (DBConn) Model

func (m DBConn) Model(data interface{}) orm.ORMModel

type Model

type Model struct {
	Tx        DBConn
	Data      interface{}
	OpList    *sync.Map // key:操作模式Mode value:操作值
	WhereList bson.M
}

func (Model) Asc

func (m Model) Asc(condition interface{}) orm.ORMModel

正序

func (Model) Create

func (m Model) Create(data interface{}) (id string, err error)

func (Model) Delete

func (m Model) Delete(data interface{}) error

删除

func (Model) Desc

func (m Model) Desc(condition interface{}) orm.ORMModel

逆序

func (Model) Find

func (m Model) Find() orm.ORMQuary

查询数据

func (Model) GetCollection

func (m Model) GetCollection(dest interface{}) string

获取集合

func (Model) Limit

func (m Model) Limit(limit int) orm.ORMModel

限制查询的数量

func (Model) Offset

func (m Model) Offset(offset int) orm.ORMModel

跳过查询的数量

func (Model) Page

func (m Model) Page(page, limit int) orm.ORMModel

func (Model) Save

func (m Model) Save(data interface{}) (id string, err error)

更新或插入数据

func (Model) Update

func (m Model) Update(data interface{}) error

修改

func (Model) Where

func (m Model) Where(condition interface{}) orm.ORMModel

限制条件

func (Model) WhereGt

func (m Model) WhereGt(condition interface{}) orm.ORMModel

func (Model) WhereIs

func (m Model) WhereIs(key string, value any) orm.ORMModel

func (Model) WhereLt

func (m Model) WhereLt(condition interface{}) orm.ORMModel

func (Model) WhereNot

func (m Model) WhereNot(condition interface{}) orm.ORMModel

func (Model) WhereOr

func (m Model) WhereOr(condition interface{}) orm.ORMModel

type Quary

type Quary struct {
	Where bson.M
	// contains filtered or unexported fields
}

func (Quary) All

func (q Quary) All(data interface{}) error

func (Quary) Count

func (q Quary) Count() (i int64, err error)

func (Quary) One

func (q Quary) One(data interface{}) error

type Table

type Table interface {
	TableName() string
}

Jump to

Keyboard shortcuts

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