api.spaceplanner.app

Spaceplanner API
git clone git://jacobedwards.org/api.spaceplanner.app
Log | Files | Refs

commit 97f348a807f72351b26d09b30c378eb7e8f75426
parent e57a7d8e5f29aeb05dfb075ebe02b9a83dc41d67
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Wed, 16 Oct 2024 20:32:32 -0700

Use patch op constants everywhere in floorplan_data.go

Diffstat:
Minternal/backend/floorplan_data.go | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/internal/backend/floorplan_data.go b/internal/backend/floorplan_data.go @@ -367,7 +367,7 @@ func (e *Env) ReplaceFloorplanData(tx *sql.Tx, user string, floorplan ObjectID, } createPatch := func(id ObjectID, value any) Patch { return Patch{ - Op: "new", + Op: PatchNew, Path: id.Path(), Value: value, } @@ -497,7 +497,7 @@ func (e *Env) PatchFloorplanData(tx *sql.Tx, user string, floorplan ObjectID, pa return data, patchError(nil, patch.Path, err) } - if (patch.Op == "new" || patch.Op == "replace") && patch.Value == nil { + if (patch.Op == PatchNew || patch.Op == PatchReplace) && patch.Value == nil { return data, id.Error("Requires value", nil) } @@ -589,11 +589,11 @@ func applyPatch[T DBObject](e *Env, tx *sql.Tx, floorplan ObjectID, patch *Patch var err error var dbo DBObject switch patch.Op { - case "new": + case PatchNew: dbo, err = thing.Create(e, tx, floorplan) - case "replace": + case PatchReplace: dbo, err = thing.Update(e, tx, floorplan) - case "remove": + case PatchRemove: dbo, err = thing.Delete(e, tx, floorplan) default: return thing, inputID.Error("Unsupported operation", nil)