Documentation ¶
Overview ¶
*
- @Author: DollarKiller
- @Description: collection
- @Github: https://github.com/dollarkillerx
- @Date: Create in 22:15 2019-10-27
*
- @Author: DollarKiller
- @Description: db相关操作
- @Github: https://github.com/dollarkillerx
- @Date: Create in 09:31 2019-10-29
*
- @Author: DollarKiller
- @Description: 常用解决方案 只池化到DB
- @Github: https://github.com/dollarkillerx
- @Date: Create in 17:31 2019-10-28
*
- @Author: DollarKiller
- @Description: defer 对一些对象的简化
- @Github: https://github.com/dollarkillerx
- @Date: Create in 13:54 2019-10-28
*
- @Author: DollarKiller
- @Description: main
- @Github: https://github.com/dollarkillerx
- @Date: Create in 20:15 2019-10-27
*
- @Author: DollarKiller
- @Description: 对象池
- @Github: https://github.com/dollarkillerx
- @Date: Create in 20:57 2019-10-27
*
- @Author: DollarKiller
- @Description: utils
- @Github: https://github.com/dollarkillerx
- @Date: Create in 08:54 2019-10-28
Index ¶
- func Sha1Encode(str string) string
- type Collection
- func (c *Collection) CountDocuments() (int64, error)
- func (c *Collection) CreatIndex(key string, initial int32) (string, error)
- func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (c *Collection) Drop() error
- func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (c *Collection) InsertMany(data []interface{}) (*mongo.InsertManyResult, error)
- func (c *Collection) InsertOne(data interface{}) (*mongo.InsertOneResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type Database
- type Db
- func (d *Db) Database(dbName string) *Database
- func (d *Db) GetCollection(dbName, collectionName string) (collection *mongo.Collection, resultPul *ResultPul, err error)
- func (d *Db) GetDatabase(dbName string) (database *mongo.Database, ResultDb *ResultDbPul, err error)
- func (d *Db) NewCollection(dbName, collectionName string) *Collection
- func (d *Db) Ping() error
- func (d *Db) PulCollection(resultPul *ResultPul) error
- func (d *Db) PulDatabase(pul *ResultDbPul) error
- func (d *Db) SetConnMaxLifetime(time time.Duration)
- func (d *Db) SetMaxOpenConn(maxOpen int)
- func (d *Db) SetNotLimitedOpen(open bool)
- type DbCollection
- func (d *DbCollection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (d *DbCollection) CreatIndex(key string, initial int32) (idxRet string, err error)
- func (d *DbCollection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (d *DbCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (d *DbCollection) Drop() error
- func (d *DbCollection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (d *DbCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (d *DbCollection) GetCollection() (*mongo.Collection, *ResultDbPul, error)
- func (d *DbCollection) Indexes() mongo.IndexView
- func (d *DbCollection) InsertMany(ctx context.Context, documents []interface{}, ...) (*mongo.InsertManyResult, error)
- func (d *DbCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (d *DbCollection) PulCollection(data *ResultDbPul) error
- func (d *DbCollection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (d *DbCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type ObjPool
- type PoolGenerateItem
- type ResultDbPul
- type ResultPul
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) CreatIndex ¶
func (c *Collection) CreatIndex(key string, initial int32) (string, error)
设置索引
func (*Collection) DeleteOne ¶
func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
删除数据
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
查询多条数据 方式一
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
查询单条数据
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(data []interface{}) (*mongo.InsertManyResult, error)
插件多条数据
func (*Collection) InsertOne ¶
func (c *Collection) InsertOne(data interface{}) (*mongo.InsertOneResult, error)
插入一条数据
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
修改数据
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) Collection ¶
func (d *Database) Collection(name string, opts ...*options.CollectionOptions) *DbCollection
type Db ¶
db
func (*Db) GetCollection ¶
func (d *Db) GetCollection(dbName, collectionName string) (collection *mongo.Collection, resultPul *ResultPul, err error)
暴露出去的 获取和放回
func (*Db) GetDatabase ¶
func (d *Db) GetDatabase(dbName string) (database *mongo.Database, ResultDb *ResultDbPul, err error)
暴露
func (*Db) NewCollection ¶
func (d *Db) NewCollection(dbName, collectionName string) *Collection
new
func (*Db) PulCollection ¶
func (*Db) PulDatabase ¶
func (d *Db) PulDatabase(pul *ResultDbPul) error
type DbCollection ¶
type DbCollection struct {
// contains filtered or unexported fields
}
func (*DbCollection) CountDocuments ¶
func (d *DbCollection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
func (*DbCollection) CreatIndex ¶
func (d *DbCollection) CreatIndex(key string, initial int32) (idxRet string, err error)
设置索引
func (*DbCollection) DeleteMany ¶
func (d *DbCollection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*DbCollection) DeleteOne ¶
func (d *DbCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*DbCollection) Drop ¶
func (d *DbCollection) Drop() error
func (*DbCollection) Find ¶
func (d *DbCollection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
func (*DbCollection) FindOne ¶
func (d *DbCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
func (*DbCollection) GetCollection ¶
func (d *DbCollection) GetCollection() (*mongo.Collection, *ResultDbPul, error)
暴露出去
func (*DbCollection) Indexes ¶
func (d *DbCollection) Indexes() mongo.IndexView
func (*DbCollection) InsertMany ¶
func (d *DbCollection) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
func (*DbCollection) InsertOne ¶
func (d *DbCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*DbCollection) PulCollection ¶
func (d *DbCollection) PulCollection(data *ResultDbPul) error
放回
func (*DbCollection) UpdateMany ¶
func (d *DbCollection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*DbCollection) UpdateOne ¶
func (d *DbCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type PoolGenerateItem ¶
type PoolGenerateItem func() interface{}
type ResultDbPul ¶
type ResultDbPul struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* * @Author: DollarKiller * @Description: clog 日志打印 * @Github: https://github.com/dollarkillerx * @Date: Create in 09:16 2019-10-28
|
* * @Author: DollarKiller * @Description: clog 日志打印 * @Github: https://github.com/dollarkillerx * @Date: Create in 09:16 2019-10-28 |
examples
|
|
curd_demo1
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 16:21 2019-10-28
|
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 16:21 2019-10-28 |
db_pro
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 10:15 2019-10-29
|
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 10:15 2019-10-29 |
db_pro1
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 10:29 2019-10-29
|
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 10:29 2019-10-29 |
simple
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 20:42 2019-10-27
|
* * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 20:42 2019-10-27 |
simple_a
* * @Author: DollarKiller * @Description: 对外暴露 * @Github: https://github.com/dollarkillerx * @Date: Create in 14:03 2019-10-28
|
* * @Author: DollarKiller * @Description: 对外暴露 * @Github: https://github.com/dollarkillerx * @Date: Create in 14:03 2019-10-28 |
mongo-driver
|
|
bson
Package bson is a library for reading, writing, and manipulating BSON.
|
Package bson is a library for reading, writing, and manipulating BSON. |
bson/bsoncodec
Package bsoncodec provides a system for encoding values to BSON representations and decoding values from BSON representations.
|
Package bsoncodec provides a system for encoding values to BSON representations and decoding values from BSON representations. |
bson/bsonrw
Package bsonrw contains abstractions for reading and writing BSON and BSON like types from sources.
|
Package bsonrw contains abstractions for reading and writing BSON and BSON like types from sources. |
bson/bsontype
Package bsontype is a utility package that contains types for each BSON type and the a stringifier for the Type to enable easier debugging when working with BSON.
|
Package bsontype is a utility package that contains types for each BSON type and the a stringifier for the Type to enable easier debugging when working with BSON. |
bson/primitive
Package primitive contains types similar to Go primitives for BSON types can do not have direct Go primitive representations.
|
Package primitive contains types similar to Go primitives for BSON types can do not have direct Go primitive representations. |
internal/testutil/israce
Package israce reports if the Go race detector is enabled.
|
Package israce reports if the Go race detector is enabled. |
mongo
Package mongo provides a MongoDB Driver API for Go.
|
Package mongo provides a MongoDB Driver API for Go. |
x/bsonx/bsoncore
Package bsoncore contains functions that can be used to encode and decode BSON elements and values to or from a slice of bytes.
|
Package bsoncore contains functions that can be used to encode and decode BSON elements and values to or from a slice of bytes. |
x/mongo/driver/auth
Package auth is not for public use.
|
Package auth is not for public use. |
x/mongo/driver/topology
Package topology contains types that handles the discovery, monitoring, and selection of servers.
|
Package topology contains types that handles the discovery, monitoring, and selection of servers. |
Click to show internal directories.
Click to hide internal directories.