drizzle-team / drizzle-team/drizzle-orm

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

Open
#2,391 2 comments 22 reactions 0 assignees View on GitHub
enhancement has-pr implemented-in-beta priority qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### 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.

```ts
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:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.