updated mongo driver dependencies to v2
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m27s

This commit is contained in:
2026-04-21 12:11:38 +02:00
parent 84b87d61f2
commit 0c37dd5576
36 changed files with 187 additions and 582 deletions
+9 -22
View File
@@ -2,11 +2,11 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"iter"
)
@@ -51,13 +51,15 @@ func (c *Coll[TData]) createFindQuery(ctx context.Context, filter bson.M, opts .
}
}
convOpts := make([]*options.AggregateOptions, 0, len(opts))
convOpts := make([]options.Lister[options.AggregateOptions], 0, len(opts))
for _, v := range opts {
vConv, err := convertFindOpt(v)
if err != nil {
return nil, exerr.Wrap(err, "mongo-aggregation failed").Any("pipeline", pipeline).Str("collection", c.Name()).Build()
}
convOpts = append(convOpts, vConv)
if vConv != nil {
convOpts = append(convOpts, vConv)
}
}
cursor, err := c.coll.Aggregate(ctx, pipeline, convOpts...)
@@ -137,7 +139,7 @@ func (c *Coll[TData]) FindIterate(ctx context.Context, filter bson.M, opts ...*o
}
// converts FindOptions to AggregateOptions
func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
func convertFindOpt(v *options.FindOptions) (*options.AggregateOptionsBuilder, error) {
if v == nil {
return nil, nil
}
@@ -157,7 +159,7 @@ func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
r.SetCollation(v.Collation)
}
if v.Comment != nil {
r.SetComment(*v.Comment)
r.SetComment(v.Comment)
}
if v.CursorType != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'CursorType' (cannot convert to AggregateOptions)").Build()
@@ -165,33 +167,18 @@ func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
if v.Hint != nil {
r.SetHint(v.Hint)
}
if v.Max != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Max' (cannot convert to AggregateOptions)").Build()
}
if v.MaxAwaitTime != nil {
r.SetMaxAwaitTime(*v.MaxAwaitTime)
}
if v.MaxTime != nil {
r.SetMaxTime(*v.MaxTime)
}
if v.Min != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Min' (cannot convert to AggregateOptions)").Build()
}
if v.NoCursorTimeout != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'NoCursorTimeout' (cannot convert to AggregateOptions)").Build()
}
if v.OplogReplay != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'OplogReplay' (cannot convert to AggregateOptions)").Build()
}
if v.ReturnKey != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'ReturnKey' (cannot convert to AggregateOptions)").Build()
}
if v.ShowRecordID != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'ShowRecordID' (cannot convert to AggregateOptions)").Build()
}
if v.Snapshot != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Snapshot' (cannot convert to AggregateOptions)").Build()
}
if v.Let != nil {
r.SetLet(v.Let)
}