-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggregater.go
More file actions
29 lines (24 loc) · 781 Bytes
/
Copy pathaggregater.go
File metadata and controls
29 lines (24 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package nosql
import (
"context"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
// Aggregater is a part of the mongo.Collection interface.
type Aggregater interface {
Aggregate(
ctx context.Context, pipeline interface{}, opts ...options.Lister[options.AggregateOptions],
) (*mongo.Cursor, error)
}
// AggregateMany executes an aggregate command against the collection.
// Any reference to mongo.Collection conforms to Aggregater interface.
func AggregateMany(
ctx context.Context, aggregater Aggregater, pipeline interface{}, opts ...options.Lister[options.AggregateOptions],
) *ManyResult {
cursor, err := aggregater.Aggregate(ctx, pipeline, opts...)
return &ManyResult{
ctx: ctx,
cursor: cursor,
err: err,
}
}