Inline queries or anonymous queries

Not sure if those are the best names for what I am proposing, but here is what I am thinking.

In a javascript query I sometimes need to call a SQL query to get some data from my database and then use the results. Currently I can trigger the query with an onSuccess promise and check the results. But I have to create and track another entity - the query I triggered. That adds complexity. To run a bulk query that needs a custom array, I need two js queries, a SQL query and a global (temp state) var.

What if I could create and run a query within javascript, keep all of the logic encapsulated in one place.

I am a huge fan of low-code platforms having used them for decades (I got MC Access v1.0 the week it was released and this was an example of what we at the time called 4GL for fourth generation language) and it is awesome that the concept has moved to the web. But one of the balances that is hard to strike is code vs GUI.

GUI makes things much easier to get started with and much faster to develop (in most cases.) But if you try to accomplish nearly everything in the GUI, eventually the GUI gets harder to use than code (OutSystems anyone?) and turns into an overly complicated web of unsearchable and difficult to unravel little tiny silos of logic. (I haven’t tried any of the so-called no-code platforms, but they seem like a fantasy to me.)

Access has a full fledged language that you can use as much or as little of it vs GUI as is appropriate to your application. You can create query objects (via SQL or GUI like Retool does) and run them from other queries or code. Or you can generate an ad hoc query within code and execute it. You can make functions that were called within the query as well. Neither code nor GUI is a second class citizen.

So I guess I am proposing raising the status of JS within Retool which will might make it less “low-code” for some projects and that is a good thing!