File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ type QueryI interface {
57
57
One (result interface {}) error
58
58
All (result interface {}) error
59
59
Count () (n int64 , err error )
60
+ EstimatedCount () (n int64 , err error )
60
61
Distinct (key string , result interface {}) error
61
62
Cursor () CursorI
62
63
Apply (change Change , result interface {}) error
Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ func (q *Query) Count() (n int64, err error) {
221
221
return q .collection .CountDocuments (q .ctx , q .filter , opt )
222
222
}
223
223
224
+ // EstimatedCount count the number of the collection by using the metadata
225
+ func (q * Query ) EstimatedCount () (n int64 , err error ) {
226
+ return q .collection .EstimatedDocumentCount (q .ctx )
227
+ }
228
+
224
229
// Distinct gets the unique value of the specified field in the collection and return it in the form of slice
225
230
// result should be passed a pointer to slice
226
231
// The function will verify whether the static type of the elements in the result slice is consistent with the data type obtained in mongodb
You can’t perform that action at this time.
0 commit comments