Writing Typesafe sql?
Advice for writing typesafe sql with some linter or something? I'm using supabase for a while now, and the only thing i don't like is writing sql without any type hint or autocomplete, there are some way of getting this right? vscode extensions or something?
4 Replies
I'd check out one of these:
- Kysely, a typesafe query builder https://github.com/koskimas/kysely
- ts-sql-plugin, typescript completion directly for your sql queries https://github.com/xialvjun/ts-sql-plugin
isnt that what prisma is for?
Prisma is an ORM, and like most ORMs give u the minimun of sql that u need for query something. But query is not my problem, i need to do advanced sql things like Triggers, Functions and Policies, because that's how Supabase works.
Kysely doesn't support these. Here's an issue from a while back about triggers https://github.com/koskimas/kysely/issues/84