mgodb

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MDB_URL string = ":27017"
)

Functions

This section is empty.

Types

type MgoDB

type MgoDB struct {
	Url    string `json:"url"`
	DbName string `json:"db_name"`
	*mgo.Session
	*mgo.Database
}

MgoDB 数据库结构体

func Init

func Init(url, dbName string) (*MgoDB, error)

Init 初始化数据库

func (*MgoDB) CheckValid added in v1.0.7

func (my *MgoDB) CheckValid() bool

Check see if the db is valid

func (*MgoDB) CountWithCond

func (my *MgoDB) CountWithCond(cName string, cond interface{}) (int, error)

CountWithCond ...

func (*MgoDB) FakeDel

func (my *MgoDB) FakeDel(cName string, data interface{}) bool

FakeDel 假删除,若status为1,则说明是已删除数据

func (*MgoDB) GetPage

func (my *MgoDB) GetPage(cName string, page int, size int) ([]interface{}, error)

GetPage 返回一页数据,page指定页数(最小是0页),size指定一页的大小

func (*MgoDB) HowMany

func (my *MgoDB) HowMany(cName string) (int, error)

HowMany 返回一个集合中有多少个文档

func (*MgoDB) Insert

func (my *MgoDB) Insert(cName string, data ...interface{}) error

Insert 插入文档到指定的集合中,若指定集合不存在,则新建,成功返回nil,失败返回error

func (*MgoDB) Search

func (my *MgoDB) Search(cName string, q interface{}, page int, size int) ([]interface{}, error)

Search 查找集合中满足q的前limit条文档(数据—)

func (*MgoDB) SearchAll

func (my *MgoDB) SearchAll(cName string, q interface{}) ([]interface{}, error)

SearchAll 在集合cName中查找所有满足q的文档(数据)

func (*MgoDB) SearchOne

func (my *MgoDB) SearchOne(cName, id string) (interface{}, error)

SearchOne 通过id来查找数据

func (*MgoDB) Update

func (my *MgoDB) Update(cName string, where, modify interface{}) error

Update 在指定的集合中修改数据

Jump to

Keyboard shortcuts

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