IzzyBeraja / Flags

0 stars 0 forks source link

Update the switch route to instead use the name rather than switch id #57

Open IzzyBeraja opened 1 year ago

IzzyBeraja commented 1 year ago

Currently I use UUIDs for all of my ids, but this will make the url difficult to read. Instead, I should use the name of the switch since it is unique for each of the switches owned by the currently logged in user.

IzzyBeraja commented 1 year ago

Since I'd like the name for flags and flows to be unique across both tables, I need to create an intermediary table to store them and write a uniqueness constraint. That will then ensure that these names are unique.

Why do this?

I would like for clients to be able to query flags and flows via their name. The issue is that if there are name collisions, then I'd need to find a way to avoid them like adding flow or flag, but from the perspective of the client, it doesn't matter if the data they receive comes from a flag or a flow, they just want the state.

So to accomplish this, I need to find a way to ensure that the names are unique across both tables. There isn't a constraint that works like this, but I can create a table that stores those names given the relevant flag or flow id. On that table, I can then establish a uniqueness constraint by name. This also works if in the future I add things like NUX values or other things that I'd like the client to be able to query by name.

All that being said, I need to add this table before I can confidently support this feature.