What is the recommended way to reuse SQL statements? #403
Answered
by
porsager
oskarrough
asked this question in
Q&A
-
Hello, was wondering what the recommended way to reuse SQL statements is here. I assumed const query = 'select * from posts'
await sql`${query}` // throws an error
await sql.unsafe(query) // works To avoid using the const queryById = (id) => sql`select * from posts where id = ${id}`
await queryById(42) // works |
Beta Was this translation helpful? Give feedback.
Answered by
porsager
Jun 26, 2022
Replies: 1 comment 1 reply
-
Oh yeah 😉 Functions Baby 🏋 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
porsager
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh yeah 😉 Functions Baby 🏋