mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Add callback support for a counting
This commit is contained in:
@@ -13,11 +13,14 @@ func (d *Database) Count(target interface{}, filters ...interface{}) (result int
|
||||
collection := d.GetCollectionOf(target)
|
||||
opts := options.Count()
|
||||
composed := query.Compose(filters...)
|
||||
ctx := query.WithContext(d.Context(), composed)
|
||||
|
||||
opts.Limit = composed.Limiter()
|
||||
opts.Skip = composed.Skipper()
|
||||
|
||||
result, err = collection.CountDocuments(d.Context(), composed.M(), opts)
|
||||
result, err = collection.CountDocuments(ctx, composed.M(), opts)
|
||||
|
||||
_ = composed.OnClose().Invoke(ctx, target)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user