node-sql-template-strings
node-sql-template-strings copied to clipboard
Named bindings feature request
Hello Thanks for the awesome library
Knex has a nice named bindings option, which allows to use :parametersWithColon (see docs), which in turn are supported in RDBMS editors, so we don't have to replace all ${id} with :id manually each time we're testing raw SQL
The check that named parameters are present looks pretty straightforward
How about adding something similar to sql-template-strings, so we would be able to build queries like this i.e.
sql`
SELECT * FROM books
WHERE id = :bookId
`.bind({ bookId })
Really, if you want to use that kind of syntax, you're better off using the underlying database adapter directly, most of which already support that syntax. JS telmplate strings only naturally support the ordinal position, and your suggestion really wouldn't add much in terms of support. Also, not all the database backends currently in place support named parameters vs ordinal position.