mongo adjust
This commit is contained in:
@@ -3,7 +3,6 @@ package mongo
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
@@ -248,16 +247,11 @@ func (m *MongoDB) StoreOne(obj interface{}, id string, collection_name string) (
|
||||
if err := m.createClient(mngoConfig.GetUrl(), false); err != nil {
|
||||
return "", 503, err
|
||||
}
|
||||
doc := map[string]interface{}{}
|
||||
fmt.Println("sqdqsd", obj)
|
||||
b, _ := bson.Marshal(obj)
|
||||
bson.Unmarshal(b, &doc)
|
||||
doc["_id"] = id
|
||||
targetDBCollection := CollectionMap[collection_name]
|
||||
MngoCtx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
|
||||
//defer cancel()
|
||||
|
||||
_, err := targetDBCollection.InsertOne(MngoCtx, doc)
|
||||
_, err := targetDBCollection.InsertOne(MngoCtx, obj)
|
||||
if err != nil {
|
||||
// m.Logger.Error().Msg("Couldn't insert resource: " + err.Error())
|
||||
return "", 409, err
|
||||
|
||||
Reference in New Issue
Block a user