node-sql-template-strings
node-sql-template-strings copied to clipboard
How to call stored procedure with dynamic arguments?
How can I call select * from stored_procedure('arg1', 'arg2', 'arg3')
with a dynamic number of args? So I would have an array of arguments like args = ['arg1', 'arg2', 'arg3')
that I'd like to pass to the sql-template-string, how can it be done? Could there be something like select * from stored_procedure(${args})
?
How would you do it without sql template strings?
Basically prepare a string with the length of args
, like select * from stored_procedure($1, $2, $3)
, then pass in the args
as the other parameter. I wonder if there could be a simpler way that template strings could offer for such purpose.