hi guys.. i think this might be a very basic quest...
# help
l
hi guys.. i think this might be a very basic question.. if i have a dropdown list - e.g low, medium, high.. how can i guarantee that a user cannot insert other values than these 3 items?
n
Hello @lanbau! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
b
There are many ways to do this. You can do this in your front end (app) code, of course. But to do it in your database, you can create an ENUM: https://www.postgresql.org/docs/current/datatype-enum.html
n
lanbau (2022-05-21)
b
You'd probably need to create or edit your table using the Query Editor and do it in SQL, though. But this is a bullet-proof way to make sure no unwanted data ever appears in your database.
l
thanks!
@burggraf any idea if we can use this enum for jsonb fields?
b
It’s mostly designed for text
But you could try it with a jsonb. I’ve never tried