Documentation ¶
Index ¶
- func Disconnect()
- func Init()
- type Collection
- func (c *Collection) Count(selector interface{}) (int64, error)
- func (c *Collection) Find(filter interface{}) *Session
- 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 Session
- func (s *Session) All(result interface{}) error
- func (s *Session) C(collection string) *Collection
- func (s *Session) Client() *mongo.Client
- func (s *Session) Connect() error
- func (s *Session) DB(db string) *Database
- func (s *Session) Disconnect()
- func (s *Session) Limit(limit int64) *Session
- func (s *Session) One(result interface{}) error
- func (s *Session) Ping() error
- func (s *Session) SetPoolLimit(limit uint64)
- func (s *Session) SetUri(uri string)
- func (s *Session) Skip(skip int64) *Session
- func (s *Session) Sort(sort interface{}) *Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶ added in v1.1.22
type Collection struct {
// contains filtered or unexported fields
}
Collection mongo-driver collection
func (*Collection) Count ¶ added in v1.1.22
func (c *Collection) Count(selector interface{}) (int64, error)
Count 获取与筛选器匹配的文档数
func (*Collection) Find ¶ added in v1.1.22
func (c *Collection) Find(filter interface{}) *Session
Find 按给定筛选器查找文档
func (*Collection) Insert ¶ added in v1.1.22
func (c *Collection) Insert(document interface{}) error
Insert 将单个文档插入集合
func (*Collection) InsertAll ¶ added in v1.1.22
func (c *Collection) InsertAll(documents []interface{}) error
InsertAll 插入提供的文档集
func (*Collection) InsertAllWithResult ¶ added in v1.1.22
func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)
InsertAllWithResult 插入提供的文档集并返回插入的结果
func (*Collection) InsertWithResult ¶ added in v1.1.22
func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)
InsertWithResult 在集合中插入一个文档,并返回插入一个结果
func (*Collection) Remove ¶ added in v1.1.22
func (c *Collection) Remove(selector interface{}) error
Remove 从集合中删除单个文档
func (*Collection) RemoveAll ¶ added in v1.1.22
func (c *Collection) RemoveAll(selector interface{}) error
RemoveAll 从集合中删除多个文档
func (*Collection) RemoveID ¶ added in v1.1.22
func (c *Collection) RemoveID(id interface{}) error
RemoveID 按id从集合中删除单个文档
func (*Collection) Update ¶ added in v1.1.22
func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error
Update 更新集合中的单个文档
func (*Collection) UpdateAll ¶ added in v1.1.22
func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)
UpdateAll 更新集合中的多个文档
func (*Collection) UpdateID ¶ added in v1.1.22
func (c *Collection) UpdateID(id interface{}, update interface{}) error
UpdateID 按id更新集合中的单个文档
func (*Collection) UpdateWithResult ¶ added in v1.1.22
func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)
UpdateWithResult 更新集合中的单个文档并返回更新结果
type Database ¶ added in v1.1.22
type Database struct {
// contains filtered or unexported fields
}
Database mongo-driver database
func (*Database) CollectionNames ¶ added in v1.1.22
CollectionNames 返回数据库中存在的所有集合名称
type Session ¶ added in v1.1.22
type Session struct {
// contains filtered or unexported fields
}
Session mongo session
var S *Session
func (*Session) SetPoolLimit ¶ added in v1.1.22
SetPoolLimit 指定服务器连接池的最大值
Click to show internal directories.
Click to hide internal directories.