22 lines
442 B
Go
22 lines
442 B
Go
package wmo
|
|
|
|
import (
|
|
"context"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
func (c *Coll[TData]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, opts ...*options.AggregateOptions) ([]TData, error) {
|
|
cursor, err := c.coll.Aggregate(ctx, pipeline, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res, err := c.decodeAll(ctx, cursor)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return res, nil
|
|
}
|