3 ms·
There are much better solutions than ORMs that let you use native SQL but guarantee that you can't have SQL injections. This blog post, https://gajus.medium.com
by hn_throwaway_99 6y ago
There are much better solutions than ORMs that let you use native SQL but guarantee that you can't have SQL injections. This blog post, https://gajus.medium.com/stop-using-knex-js-and-earn-30-bf410349856c https://gajus.medium.com/stop-using-knex-js-and-earn-30-bf41..., is by the author of Slonik, of which I'm a huge fan. It takes advantage of tagged template literals in Javascript to make it feel like you're just concatenating strings, but actually you are creating prepared statements. E.g.
sql`SELECT foo FROM bar WHERE id = ${userEnteredId}`
gets converted into an object that is basically:
{ query: 'SELECT foo FROM bar WHERE id = ?', params: [userEnteredId] }