Drizzle ORM integration #783
Replies: 5 comments 4 replies
-
figured out a solution to the second pain point, there is |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your insights on how you got Drizzle to work with Electric SQL. Regarding your first question, our current workflow relies on Prisma to generate an Electric client. The typings of our Electric client re-use the typings from the generated Prisma client. Normally, when using a Prisma version we support you should not get type errors in the generated client. As to Zod, we use Zod for runtime validation of user input. A trickier part of integrating Drizzle with Electric will be data type support. For example, Electric supports booleans, dates, etc. Booleans are true booleans in Postgres but are numbers (0 or 1) in the local SQLite database. Therefore, our Electric client converts the user's booleans into 0 or 1 and when reading does the opposite conversion. Not sure how this would work when integrating Drizzle because our client only does this conversion when using our Prisma-inspired API but not when using raw queries. |
Beta Was this translation helpful? Give feedback.
-
Hi, I collected all the things about drizzle + electric in a repo: https://github.com/PeterZainzinger/electric-drizzle . It contains its own code generator, which is bit limited. It should demonstrate some ideas how to use electric with external query libraries. Feel free to give feedback |
Beta Was this translation helpful? Give feedback.
-
Hey @PeterZainzinger and @kevin-dp curious if https://github.com/farreldarian/prisma-generator-drizzle from @farreldarian would help address some issues that were mentioned in this thread |
Beta Was this translation helpful? Give feedback.
-
👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/ You can read more about why we made the decision at https://next.electric-sql.com/about We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback. We're now moving the temporary repo back here. As part of that migration we're closing all the old issues, PRs, and discussions. We really appreciate you taking the time to start this discussion! If it's still relevant in the new system, please reopen. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am trying to integrate electric-sql with drizzle-orm, I already got a basic proof-of-concept working without much effort. My approach was:
comments
table on the server side with.
and apply these migrations to postgres proxy.
in
schema.ts
.
The trick there is to use
toSQL()
method. I read a bit the drizzle source code, for more complex queries something likemapRelationalRow
has to be used.Everything basically works, there are two main pain points:
Does somebody have input for these?
In general I would really like to see drizzle orm support because I think its a really elegant., powerfull and also lightweight library that could be leveraged without crazy effort from electric-sql.
Peter
Beta Was this translation helpful? Give feedback.
All reactions