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.
SubscribeRelated
defineRelationsone()many()One-to-oneOne-to-manyMany-to-manyPredefined filtersForeign keys