drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.57k stars 490 forks source link

[FEATURE]: Add ability to use relations in `returning()` #2325

Open jakeleventhal opened 1 month ago

jakeleventhal commented 1 month ago

Describe what you want

I want to be able to specify with in a returning clause. For instance:

// Current code
await db.update(users).set({ email }).where(...);
const newUser = await db.query.users.findFirst({ where: ..., with: {settings: true });

// Proposed code
const newUser = await db.update(users).set({ email }).where(...).returning({ with: {settings: true} });