mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-06-12 16:53:35 +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)
|
collection := d.GetCollectionOf(target)
|
||||||
opts := options.Count()
|
opts := options.Count()
|
||||||
composed := query.Compose(filters...)
|
composed := query.Compose(filters...)
|
||||||
|
ctx := query.WithContext(d.Context(), composed)
|
||||||
|
|
||||||
opts.Limit = composed.Limiter()
|
opts.Limit = composed.Limiter()
|
||||||
opts.Skip = composed.Skipper()
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user