mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
扩展CountDocument条件参数
This commit is contained in:
@@ -52,10 +52,10 @@ func (mm *MongoModule) TakeSession() Session {
|
|||||||
return Session{Client: mm.client, maxOperatorTimeOut: mm.maxOperatorTimeOut}
|
return Session{Client: mm.client, maxOperatorTimeOut: mm.maxOperatorTimeOut}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) CountDocument(db string, collection string) (int64, error) {
|
func (s *Session) CountDocument(db string, collection string, filter interface{}) (int64, error) {
|
||||||
ctxTimeout, cancel := s.GetDefaultContext()
|
ctxTimeout, cancel := s.GetDefaultContext()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
return s.Database(db).Collection(collection).CountDocuments(ctxTimeout, bson.D{})
|
return s.Database(db).Collection(collection).CountDocuments(ctxTimeout, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) NextSeq(db string, collection string, id interface{}) (int, error) {
|
func (s *Session) NextSeq(db string, collection string, id interface{}) (int, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user