Hi,
I read the docs about MariaDB and actually, I found the sql calls very boring (I'm used to async/await that Js provide).
To explain my thoughts, let's explore a minimal example of a package that making some SQL calls in order to check if a user if whitelisted and banned:
In fact, asynchrone is cool, but not readable, I like my script when they are linear. A -> B -> C. But with this architecture, I can't do it (or pretty badly).
I'm used to FiveM, we had promise and coroutine and so.
If anyone have a good workaround or an idea on how to improve this readability, please, let me know
Izio.
I read the docs about MariaDB and actually, I found the sql calls very boring (I'm used to async/await that Js provide).
To explain my thoughts, let's explore a minimal example of a package that making some SQL calls in order to check if a user if whitelisted and banned:
Code:
function authentificationCheck(player) local steamId = GetPlayerSteamId(player) -- whitelist check if enable if the config if (config("whitelist")) then query("SELECT * FROM users WHERE steam = ?", {steamId}, whitelistCheck, player) end -- ban check: so Should I prepare another query here end function whitelistCheck(player) local rows = mariadb_get_row_count() if (rows) then local isWhitelisted = mariadb_get_value_name(1, "is_whitelisted"); if (not(isWhitelisted)) then return KickPlayer(player, "Tu n'es pas whitelisté.") end end -- Should I prepare another query here end -- that both would be treated here? function banCheck(player) end AddEvent("OnPlayerSteamAuth", authentificationCheck)
I'm used to FiveM, we had promise and coroutine and so.
If anyone have a good workaround or an idea on how to improve this readability, please, let me know
Izio.
Comment