We utilize a version of what you are asking for that runs a bit like this (uses a generated SQL statement and then executes it as part of a CRUD operation):
Here, the generateCreateStatement.data is a JS query, and we pass the results along to the DB via EXEC. This particular operation goes into a on-prem SQL database.
A more complex delete statement using the same principle:
My colleague did a bit of a write-up on our generic CRUD implementation that fleshes this out a bit more (Do I need separate queries...), however I think you just need these building blocks to get started.