db

package
v0.0.0-...-fabc42a Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db interface {
	Connect(hosts, db string) error   //连接
	OpenDb(db string) error           //打开库
	OpenTable(table string)           //开打表
	Query(query interface{}) error    //查询
	Insert(docs ...interface{}) error //写入
	Close() error                     //关闭连接
}

Db 定义了一个对存储操作的接口

type MongoClient

type MongoClient struct {
	Hosts      string
	Database   string
	Collection string
	Session
}

Mongo 定义mongo 操作实例

func (*MongoClient) C

func (m *MongoClient) C()

func (*MongoClient) Close

func (m *MongoClient) Close()

func (*MongoClient) Connect

func (m *MongoClient) Connect() error

func (*MongoClient) DB

func (m *MongoClient) DB()

func (*MongoClient) GetCollection

func (m *MongoClient) GetCollection() *mgo.Collection

type MongoGridfs

type MongoGridfs struct {
	MongoClient
	GridFS *mgo.GridFS
}

func (*MongoGridfs) C

func (m *MongoGridfs) C()

func (*MongoGridfs) GetGridFs

func (m *MongoGridfs) GetGridFs() *mgo.GridFS

type Session

type Session struct {
	S  *mgo.Session
	Db *mgo.Database
	C  *mgo.Collection
}

Jump to

Keyboard shortcuts

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