v0.0.248 exerr in wmo package
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 55s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 55s
This commit is contained in:
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
)
|
||||
|
||||
func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, error) {
|
||||
insRes, err := c.coll.InsertOne(ctx, valueIn)
|
||||
if err != nil {
|
||||
return *new(TData), err
|
||||
return *new(TData), exerr.Wrap(err, "mongo-query[insert-one] failed").Str("collection", c.Name()).Build()
|
||||
}
|
||||
|
||||
mongoRes := c.coll.FindOne(ctx, bson.M{"_id": insRes.InsertedID})
|
||||
@@ -19,5 +20,10 @@ func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, erro
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) InsertMany(ctx context.Context, valueIn []TData) (*mongo.InsertManyResult, error) {
|
||||
return c.coll.InsertMany(ctx, langext.ArrayToInterface(valueIn))
|
||||
insRes, err := c.coll.InsertMany(ctx, langext.ArrayToInterface(valueIn))
|
||||
if err != nil {
|
||||
return nil, exerr.Wrap(err, "mongo-query[insert-many] failed").Int("len(valueIn)", len(valueIn)).Str("collection", c.Name()).Build()
|
||||
}
|
||||
|
||||
return insRes, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user