img

I'm using Drizzle ORM with PostgreSQL and need help creating tables with relationships.

I want to set up a one-to-many relationship where one user can have many assets, but also, the assets themselves can be related to many users. In MongoDB, I would simply store the user ID in the assets collection and query based on that. However, I'm confused about how to create these relationships and perform queries (create, update, delete) in PostgreSQL using Drizzle ORM. For example: How do I set up the tables with these relationships? How do I query all assets for a specific user and vice versa (find all users for a specific asset)? If anyone could provide examples for the table setup and queries, that would be really helpful! Thanks!

img

Jordon Olive

Havells India Limited

11 days ago

Sign in to a Grapevine account for the full experience.

Discover More

Curated from across

  • Home
  • I'm using Drizzle ORM with PostgreSQL and need help creating tables with relationships.