Get column value to parameterize a SaaS config site

Hi,
I’m stuck in this, maybe is something easy, but I really can’t figute out how to do it in another way.

I have a table that is use to provide the config for each SaaS instance, making the front customize basing in data that comes from previous database table configured:

id | business_id(int) | config_name(varchar) | config_value(varchar) | onload(enum, yes, no)
1 | 1 | book_start | 08:00 | yes
1 | 1 | book_end | 18:00 | yes
1 | 1 | book_duration | 60 | yes

Keeping in mind that will be exists a lot of business_id the saving order always will be:

book_start
book_end
book_duration

So, I have in the server action a first Database Query with a simple condicion (where) to get the business_id and column onload to 'yes', all this to autoload the serverconnect in front page, all the ‘onload’ to yes will be the parameterize data for each business in the front.

The idea is to to construct a slots book for timing so each business can adapt his own schedule.

Right now to access the propper value I use in the Server Action a “Set Value” from the query to output the value in this way:

Set Value book_start = onload[0].config_value.where('config_name', '==', 'book_start')
Set Value book_start = onload[1].config_value.where('config_name', '==', 'book_end')
Set Value book_start = onload[2].config_value.where('config_name', '==', 'book_duration')

As you can see the index is static because I suppose that the “Database Insert” in Server Action always will save in the same order.

And the question is if that is correct way to do it, what happend if by A or B motive the Database Insert not save in the same order, that will break their front page obviously.

There area another easy way to access to the right value from the colum_name, something like?;
If "business_id" is '1' and, "onload" is yes' and "config_name" is 'book_start' in another way?

Thanks in advance.

@wappler_ambassadors

Community Page
Last updated: