cliffordfajardo
03/12/2022, 11:59 PMFROM cities SELECT * WHERE zipcode = '95555' AND state = 'California'
supabase
const { data, error } = await supabase
.from('cities')
.filter('zipcode', 'eq', 'category)
Needle
03/12/2022, 11:59 PM/title
command!
We have solved your problem?
Click the button below to archive it.garyaustin
03/13/2022, 12:04 AMNeedle
03/13/2022, 12:04 AMgaryaustin
03/13/2022, 12:06 AMcliffordfajardo
03/13/2022, 12:06 AMcliffordfajardo
03/13/2022, 12:10 AMsupabase.execute(`SELECT * FROM cities WHERE zipcode=${zipcode} AND state = ${}`)
Love supbase auth and the web UI for managing DB, but learning new SQL API abstractions can sometimes feel cumbersome. The pro of SQL is I can take that common query language anywhere & of course be able to debug the query planner more easilygaryaustin
03/13/2022, 12:11 AMScott P
03/13/2022, 12:17 AMcliffordfajardo
03/13/2022, 12:20 AMScott P
03/13/2022, 12:23 AMgaryaustin
03/13/2022, 12:25 AMcliffordfajardo
03/13/2022, 12:25 AM# abstraction comes from libaries like this:
import {sql} from '...supabase'
const result = sql`SELECT * FROM ...`
I've seen several libraries that offer this nice abstraction and guard against the aforementioned problems you all mentioned.
There's an entire section listed below addressing the concerns you mentioned here by Slonik's creator. This guy makes tons of DB libraries, he's a cool guy
https://github.com/gajus/slonik#protecting-against-unsafe-value-interpolation
pgtyped is really nice
- https://pgtyped.vercel.app/garyaustin
03/13/2022, 12:31 AMcliffordfajardo
03/13/2022, 12:43 AMslonik
in particular is node only. I think I saw a go lang implementation recently I will circle back and share later on
I think he made a library out out of the template literal sql
function I shared above which is decoupled from the slonik
client
Also postgres.js
supports the same raw SQL queries, and like the slonik
library above, you need to pass your SQL query to the sql
template literal function
Attached are images from slonik and postgres.jsgaryaustin
03/13/2022, 12:45 AM