Documentation ¶
Index ¶
- Variables
- type Collection
- func (c *Collection) Count(selector interface{}) (int64, error)
- func (c *Collection) Find(filter interface{}) *MongoSession
- func (c *Collection) Insert(document interface{}) error
- func (c *Collection) InsertAll(documents []interface{}) error
- func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)
- func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)
- func (c *Collection) Remove(selector interface{}) error
- func (c *Collection) RemoveAll(selector interface{}) error
- func (c *Collection) RemoveID(id interface{}) error
- func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error
- func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)
- func (c *Collection) UpdateID(id interface{}, update interface{}) error
- func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)
- type Database
- type MongoSession
- func (s *MongoSession) All(result interface{}) error
- func (s *MongoSession) C(collection string) *Collection
- func (s *MongoSession) Client() *mongo.Client
- func (s *MongoSession) Collection(collection string) *Collection
- func (s *MongoSession) Connect() (func(), error)
- func (s *MongoSession) DB(db string) *Database
- func (s *MongoSession) Limit(limit int64) *MongoSession
- func (s *MongoSession) One(result interface{}) error
- func (s *MongoSession) Ping() error
- func (s *MongoSession) SetConnectTimeout(connectTimeout uint)
- func (s *MongoSession) SetPoolLimit(limit uint64)
- func (s *MongoSession) SetWithTimeOut(withTimeout uint)
- func (s *MongoSession) Skip(skip int64) *MongoSession
- func (s *MongoSession) Sort(sort interface{}) *MongoSession
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTimeout = 60
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection mongo驱动程序集合
func (*Collection) Count ¶
func (c *Collection) Count(selector interface{}) (int64, error)
Count 获取与筛选器匹配的文档数
func (*Collection) Find ¶
func (c *Collection) Find(filter interface{}) *MongoSession
Find 按给定筛选器查找文档
func (*Collection) Insert ¶
func (c *Collection) Insert(document interface{}) error
Insert 将单个文档插入到集合中
func (*Collection) InsertAll ¶
func (c *Collection) InsertAll(documents []interface{}) error
InsertAll 插入提供的文档
func (*Collection) InsertAllWithResult ¶
func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)
InsertAllWithResult 插入提供的文档并返回insert many result
func (*Collection) InsertWithResult ¶
func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)
InsertWithResult 将单个文档插入到集合中,并返回insert one result
func (*Collection) Remove ¶
func (c *Collection) Remove(selector interface{}) error
Remove 从集合中删除单个文档
func (*Collection) RemoveAll ¶
func (c *Collection) RemoveAll(selector interface{}) error
RemoveAll 从集合中删除多个文档
func (*Collection) RemoveID ¶
func (c *Collection) RemoveID(id interface{}) error
RemoveID 按id从集合中删除单个文档
func (*Collection) Update ¶
func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error
Update 更新集合中的单个文档
func (*Collection) UpdateAll ¶
func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)
UpdateAll 更新集合中的多个文档
func (*Collection) UpdateID ¶
func (c *Collection) UpdateID(id interface{}, update interface{}) error
UpdateID 按id更新集合中的单个文档
func (*Collection) UpdateWithResult ¶
func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)
UpdateWithResult 更新集合中的单个文档并返回更新结果
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database mongo驱动程序数据库
func (*Database) Collection ¶
func (d *Database) Collection(collection string) *Collection
Collection 设置集合名称
func (*Database) CollectionNames ¶
CollectionNames 返回数据库中存在的集合名称
type MongoSession ¶
type MongoSession struct {
// contains filtered or unexported fields
}
MongoSession mongo session
func (*MongoSession) C ¶
func (s *MongoSession) C(collection string) *Collection
C Collection 集合名称名称
func (*MongoSession) Collection ¶
func (s *MongoSession) Collection(collection string) *Collection
Collection 集合名称名称
func (*MongoSession) Connect ¶
func (s *MongoSession) Connect() (func(), error)
Connect 连接 mongo 客户端
func (*MongoSession) SetConnectTimeout ¶
func (s *MongoSession) SetConnectTimeout(connectTimeout uint)
SetConnectTimeout 连接mongodb服务超时时间 秒
func (*MongoSession) SetPoolLimit ¶
func (s *MongoSession) SetPoolLimit(limit uint64)
SetPoolLimit 指定服务器连接池的最大大小
func (*MongoSession) SetWithTimeOut ¶
func (s *MongoSession) SetWithTimeOut(withTimeout uint)
SetWithTimeOut 操作超时时间 秒
Click to show internal directories.
Click to hide internal directories.