Documentation
¶
Index ¶
- Constants
- Variables
- func Call(fn func(pool.Src) error) error
- func Close()
- func CollectionNames(dbname string) (names []string, err error)
- func DatabaseNames() (names []string, err error)
- func Error() error
- func Len() int
- func Mgo(resultPtr interface{}, operate string, option map[string]interface{}) error
- func Refresh()
- type Count
- type Find
- type Insert
- type List
- type MgoSrc
- type Operator
- type Remove
- type Update
- type UpdateAll
- type Upsert
Constants ¶
View Source
const (
MaxLen int = 5000 //分配插入
)
Variables ¶
View Source
var ( MgoPool = pool.ClassicPool( config.MGO_CONN_CAP, config.MGO_CONN_CAP/5, func() (pool.Src, error) { if err != nil || session.Ping() != nil { if session != nil { session.Close() } Refresh() } return &MgoSrc{session.Clone()}, err }, connGcSecond) )
Functions ¶
Types ¶
type Count ¶
type Count struct {
Database string // 数据库
Collection string // 集合
Query map[string]interface{} // 查询语句
}
传入数据库与集合名 | 返回文档总数
type Find ¶
type Find struct {
Database string // 数据库
Collection string // 集合
Query map[string]interface{} // 查询语句
Sort []string // 排序,用法如Sort("firstname", "-lastname"),优先按firstname正序排列,其次按lastname倒序排列
Skip int // 跳过前n个文档
Limit int // 返回最多n个文档
Select interface{} // 只查询、返回指定字段,如{"name":1}
}
在指定集合进行条件查询
type Insert ¶
type Insert struct {
Database string // 数据库
Collection string // 集合
Docs []map[string]interface{} // 文档
}
插入新数据
type Remove ¶
type Remove struct {
Database string // 数据库
Collection string // 集合
Selector map[string]interface{} // 文档选择器
}
删除数据
type Update ¶
type Update struct {
Database string // 数据库
Collection string // 集合
Selector map[string]interface{} // 文档选择器
Change map[string]interface{} // 文档更新内容
}
更新第一个匹配的数据
Click to show internal directories.
Click to hide internal directories.