This commit is contained in:
mr
2026-02-05 15:30:23 +01:00
parent 543d28e5d2
commit b9e7ce20b6
3 changed files with 4 additions and 5 deletions

View File

@@ -247,17 +247,18 @@ 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{}{"_id": id}
targetDBCollection := CollectionMap[collection_name]
MngoCtx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
//defer cancel()
_, err := targetDBCollection.InsertOne(MngoCtx, obj)
_, err := targetDBCollection.InsertOne(MngoCtx, doc)
if err != nil {
// m.Logger.Error().Msg("Couldn't insert resource: " + err.Error())
return "", 409, err
}
return id, 200, nil
return m.UpdateOne(obj, id, collection_name)
}
func (m *MongoDB) LoadOne(id string, collection_name string) (*mongo.SingleResult, int, error) {