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.52k stars 487 forks source link

[FEATURE]: column.as("alias") method #2391

Open erfanium opened 1 month ago

erfanium commented 1 month ago

Describe what you want

currently, the Column type has no as method, so I use column.getSQL().mapWith(column.mapFromDriverValue).as('alias') to properly select a column with alias.

const result = await db.select({
  sellerId: user.id.getSQL().mapWith(user.id.mapFromDriverValue).as('sellerId')
})

It would be nice to be able to just do it with:

const result = await db.select({
  sellerId: user.id.as('sellerId')
})