Skip to content
Prev Previous commit
Next Next commit
minor changes as per coderabbit
  • Loading branch information
Abhishek Singh authored and Abhishek Singh committed Oct 30, 2025
commit ec0ef7d78ecfb0babfe2001b84a2f62b8cd48740
10 changes: 7 additions & 3 deletions adapters/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ func (c *Collection[T]) DeleteMany(ctx context.Context, filter bson.M, opts ...o
// Aggregate executes an aggregation pipeline.
// Note: Decoding the results is the responsibility of the caller, as aggregation
// results can have a different structure than the collection's document type T.
func (c *Collection[T]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, opts ...options.Lister[options.AggregateOptions]) (*mongo.Cursor, error) {
func (c *Collection[T]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, opts ...options.Lister[options.AggregateOptions]) (*mongo.Cursor, context.CancelFunc, error) {
ctx, cancel := c.contextWithTimeout(ctx)
defer cancel()
return c.collection.Aggregate(ctx, pipeline, opts...)
cursor, err := c.collection.Aggregate(ctx, pipeline, opts...)
if err != nil {
cancel()
return nil, nil, err
}
return cursor, cancel, nil
}

// --- Transaction Management ---
Expand Down
2 changes: 1 addition & 1 deletion database/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func BuildDSN(

// Build query string from options safely
buildOptions := func(opts map[string]string) string {
if len(opts) == 0 {
if len(opts) == 0 || opts == nil {
return ""
}
values := url.Values{}
Expand Down