v0.0.186 convert array to interface arr

This commit is contained in:
Julian Graf 2023-07-24 09:13:19 +02:00
parent 0971f60c30
commit e909d656d9
3 changed files with 21 additions and 2 deletions

View File

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

View File

@ -459,3 +459,11 @@ func ArrExcept[T comparable](arr []T, needles ...T) []T {
}
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

@ -15,3 +15,14 @@ func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, erro
return c.decodeSingle(ctx, mongoRes)
}
func (c *Coll[TData]) InsertMany(ctx context.Context, valueIn []TData) (TData, error) {
insRes, err := c.coll.InsertMany(ctx, langext.TovalueIn)
if err != nil {
return *new(TData), err
}
mongoRes := c.coll.FindOne(ctx, bson.M{"_id": insRes.InsertedID})
return c.decodeSingle(ctx, mongoRes)
}