mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
mongodb索引新增后台创建参数
This commit is contained in:
@@ -161,19 +161,21 @@ func (s *Session) NextSeq(db string, collection string, id string) (int, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// goroutine safe
|
// goroutine safe
|
||||||
func (s *Session) EnsureIndex(db string, collection string, key []string) error {
|
func (s *Session) EnsureIndex(db string, collection string, key []string, bBackground bool) error {
|
||||||
return s.DB(db).C(collection).EnsureIndex(mgo.Index{
|
return s.DB(db).C(collection).EnsureIndex(mgo.Index{
|
||||||
Key: key,
|
Key: key,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Sparse: true,
|
Sparse: true,
|
||||||
|
Background: bBackground,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// goroutine safe
|
// goroutine safe
|
||||||
func (s *Session) EnsureUniqueIndex(db string, collection string, key []string) error {
|
func (s *Session) EnsureUniqueIndex(db string, collection string, key []string, bBackground bool) error {
|
||||||
return s.DB(db).C(collection).EnsureIndex(mgo.Index{
|
return s.DB(db).C(collection).EnsureIndex(mgo.Index{
|
||||||
Key: key,
|
Key: key,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Sparse: true,
|
Sparse: true,
|
||||||
|
Background: bBackground,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user