Drizzle / PlanetScale Table Relations
Does anyone possibly have a link to a repo I can take a look at to see how relations are setup with Drizzle ORM and PlanetScale as the database?
7 Replies
the examples in the docs work with Planetscale: https://orm.drizzle.team/docs/rqb#declaring-relations
Drizzle Queries - DrizzleORM
Drizzle ORM | %s
Yes I've been through those, I also checked out this article. https://planetscale.com/blog/working-with-related-data-using-drizzle-and-planetscale
Emulating foreign key constraints with Drizzle relationships | Plan...
Learn how to build virtual relationships between tables in PlanetScale while using the Drizzle TypeScript ORM.
For testing purposes I copied the schema from this article and still got the fk constraint error.
The tables were created to the db though, I havnt tried actually writting to it yet. Maybe it actually works.
Just wanted to see how others have done theirs.
I also found this somewhere in the docs "export const db = drizzle(connection, { schema, mode: 'planetscale' });"
here's the config that I use for Planetscale and relations
here's the table I use for users in a project, where users can have many pets. the important is that you can't specify any foreign keys directly in the table, only through seperate relations
https://github.com/AnswerOverflow/AnswerOverflow/blob/main/packages/db/src/schema.ts
I just moved @Answer Overflow over to drizzle yesterday, here’s our schema file
GitHub
AnswerOverflow/packages/db/src/schema.ts at main · AnswerOverflow/A...
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
Thanks guys! 🙏
Mark your question as solved
https://discord.com/channels/966627436387266600/1150781968552824924/1150781974768787466
https://discord.com/channels/966627436387266600/1150781968552824924/1150781974768787466