Skip to content
masterclass Buddy

Drizzle ORM · Function

relations

Drizzle relations describe table links for nested relational queries. Define them with defineRelations, use r.one or r.many, and load them with the query builder's with option.

Last updated

Syntax

defineRelations(schema, (r) => ({ table: { relation: r.one.target({ from, to, optional, alias, where }) } }))

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • defineRelations
  • one()
  • many()
  • One-to-one
  • One-to-many
  • Many-to-many
  • Predefined filters
  • Foreign keys

Source: Drizzle ORM - Drizzle Relations. Checked 2026-11-03.