db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const C_save_itv = 6 // in seconds

Variables

View Source
var (
	HandlerDatabase = make(map[string]*MyMongo)
)

Functions

func CloneBsonObject added in v1.1.0

func CloneBsonObject(obj interface{}) interface{}

============================================================================

func DatabaseClose added in v1.0.8

func DatabaseClose()

func DatabaseOpen added in v1.0.8

func DatabaseOpen()

func IsDup added in v1.0.6

func IsDup(err error) bool

func IsNotFound added in v1.0.6

func IsNotFound(err error) bool

Types

type A added in v1.0.6

type A = bson.A

type D added in v1.0.6

type D = bson.D

type Data added in v1.0.6

type Data struct {
	ConfigServer.Basic
	ID   string
	Save interface{}
}

type Database added in v1.0.6

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

func (*Database) Close added in v1.0.6

func (self *Database) Close()

func (*Database) CreateCappedCollection added in v1.0.6

func (self *Database) CreateCappedCollection(coll string, size int) error

func (*Database) CreateIndex added in v1.0.6

func (self *Database) CreateIndex(coll string, name string, keys []string, unique bool) error

func (*Database) CreateTTLIndex added in v1.0.6

func (self *Database) CreateTTLIndex(coll string, name string, key string, sec int32) error

func (*Database) Execute added in v1.0.6

func (self *Database) Execute(f func(*mongo.Database))

func (*Database) FindAndUpdate added in v1.0.6

func (self *Database) FindAndUpdate(coll string, cond interface{}, doc interface{}, proj interface{}, obj interface{}) error

func (*Database) GetAllObjects added in v1.0.6

func (self *Database) GetAllObjects(coll string, obj interface{}) error

func (*Database) GetAllObjectsByCond added in v1.0.6

func (self *Database) GetAllObjectsByCond(coll string, cond interface{}, obj interface{}) error

func (*Database) GetAllProjectionsByCond added in v1.0.6

func (self *Database) GetAllProjectionsByCond(coll string, cond interface{}, proj interface{}, obj interface{}) error

func (*Database) GetCount added in v1.0.6

func (self *Database) GetCount(coll string, cond interface{}) (int64, error)

func (*Database) GetObject added in v1.0.6

func (self *Database) GetObject(coll string, id interface{}, obj interface{}) error

func (*Database) GetObjectByCond added in v1.0.6

func (self *Database) GetObjectByCond(coll string, cond interface{}, obj interface{}) error

func (*Database) GetProjection added in v1.0.6

func (self *Database) GetProjection(coll string, id interface{}, proj interface{}, obj interface{}) error

func (*Database) GetProjectionByCond added in v1.0.6

func (self *Database) GetProjectionByCond(coll string, cond interface{}, proj interface{}, obj interface{}) error

func (*Database) HasCollection added in v1.0.6

func (self *Database) HasCollection(name string) bool

func (*Database) HasDB added in v1.0.6

func (self *Database) HasDB() bool

func (*Database) HasIndex added in v1.0.6

func (self *Database) HasIndex(coll string, name string) bool

func (*Database) Insert added in v1.0.6

func (self *Database) Insert(coll string, doc interface{}) error

func (*Database) InsertMany added in v1.0.6

func (self *Database) InsertMany(coll string, docs ...interface{}) error

func (*Database) Remove added in v1.0.6

func (self *Database) Remove(coll string, id interface{}) error

func (*Database) RemoveAll added in v1.0.6

func (self *Database) RemoveAll(coll string, cond interface{}) error

func (*Database) RemoveByCond added in v1.0.6

func (self *Database) RemoveByCond(coll string, cond interface{}) error

func (*Database) Run added in v1.0.6

func (self *Database) Run(cmd bson.D, obj interface{}) error

func (*Database) Update added in v1.0.6

func (self *Database) Update(coll string, id interface{}, doc interface{}) error

func (*Database) UpdateAll added in v1.0.6

func (self *Database) UpdateAll(coll string, cond interface{}, doc interface{}) error

func (*Database) UpdateByCond added in v1.0.6

func (self *Database) UpdateByCond(coll string, cond interface{}, doc interface{}) error

func (*Database) Upsert added in v1.0.6

func (self *Database) Upsert(coll string, id interface{}, doc interface{}) error

func (*Database) UpsertByCond added in v1.0.6

func (self *Database) UpsertByCond(coll string, cond interface{}, doc interface{}) error

type Db_mongo

type Db_mongo struct {
	Tables map[string]*mongo.Collection
	// contains filtered or unexported fields
}

func (*Db_mongo) Close

func (obj *Db_mongo) Close()

func (*Db_mongo) Delete

func (obj *Db_mongo) Delete(table string, id interface{}) error

删除文档

func (*Db_mongo) Find

func (obj *Db_mongo) Find(collectionName string, query, res []interface{})

获取

func (*Db_mongo) Foreach

func (obj *Db_mongo) Foreach(table string, query interface{}, sort string, doc interface{}, callback func(error, bool, interface{}))

获取迭代器

func (*Db_mongo) Index

func (obj *Db_mongo) Index(collectionName string, keys ...string)

创建索引

func (*Db_mongo) MapReduce

func (object *Db_mongo) MapReduce(collectionName string, query, job, res interface{}) error

func (*Db_mongo) Open

func (object *Db_mongo) Open(collectString, DBName string)

func (*Db_mongo) UseSession

func (obj *Db_mongo) UseSession(ctx context.Context, fun func(mongo.SessionContext) error) error

UseSession 使用事务

func (*Db_mongo) Write

func (obj *Db_mongo) Write(table string, id, update interface{}) error

通过id更新或插入

type E added in v1.0.6

type E = primitive.E

type HandlerData added in v1.0.6

type HandlerData struct {
	Database *Database

	Data map[string]*Data
	// contains filtered or unexported fields
}

func (*HandlerData) Isdirty added in v1.0.6

func (self *HandlerData) Isdirty(id string, Save interface{})

func (*HandlerData) Save added in v1.0.6

func (self *HandlerData) Save()

type Inter

type Inter interface {
}

type M added in v1.0.6

type M = bson.M

type MyMongo added in v1.0.6

type MyMongo struct {
	Database          *Database
	HandlerMongoTable map[string]*HandlerData
}

func Open added in v1.0.6

func Open(cnnstr string, maxPoolSize ...uint64) *MyMongo

func (*MyMongo) HandleTable added in v1.0.8

func (self *MyMongo) HandleTable(table string)

Jump to

Keyboard shortcuts

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