Skip to content

Commit

Permalink
Fixes bug when upserting widget with blanked out id
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanStonebraker committed Oct 10, 2024
1 parent d3c9959 commit 8d68e54
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions api/ws/handlers/screen-configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ func writeScreenConfiguration(screenConfig *protos.ScreenConfiguration, hctx wsH
widget.Id = formWidgetId(widget, screenConfig.Id, i)
if widget.Data != nil {
// We have widget data, but no ID, so write it to the database with a new ID
_, err := hctx.Svcs.MongoDB.Collection(dbCollections.WidgetDataName).UpdateOne(sessCtx, bson.M{
"_id": widget.Id,
}, bson.M{
"$set": widget.Data,
}, options.Update().SetUpsert(true))
widget.Data.Id = widget.Id
_, err := hctx.Svcs.MongoDB.Collection(dbCollections.WidgetDataName).InsertOne(sessCtx, widget.Data)

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8d68e54

Please sign in to comment.