Compare commits

...

2 Commits

Author SHA1 Message Date
b1d6509294 v0.0.187 forget to use function 2023-07-24 09:16:37 +02:00
e909d656d9 v0.0.186 convert array to interface arr 2023-07-24 09:13:19 +02:00
3 changed files with 16 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.185" const GoextVersion = "0.0.187"
const GoextVersionTimestamp = "2023-07-19T19:34:39+0200" const GoextVersionTimestamp = "2023-07-24T09:16:37+0200"

View File

@@ -459,3 +459,11 @@ func ArrExcept[T comparable](arr []T, needles ...T) []T {
} }
return r return r
} }
func ArrayToInterface[T any](t []T) []interface{} {
res := make([]interface{}, 0, len(t))
for i, _ := range t {
res = append(res, t[i])
}
return res
}

View File

@@ -3,6 +3,8 @@ package wmo
import ( import (
"context" "context"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
) )
func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, error) { func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, error) {
@@ -15,3 +17,7 @@ func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, erro
return c.decodeSingle(ctx, mongoRes) return c.decodeSingle(ctx, mongoRes)
} }
func (c *Coll[TData]) InsertMany(ctx context.Context, valueIn []TData) (*mongo.InsertManyResult, error) {
return c.coll.InsertMany(ctx, langext.ArrayToInterface(valueIn))
}