Map/transform selected column

Is it possible to transform a column value when we define the select? This would be super useful for when sharing a subquery as I could cololcate the transform code with it instead of having a seperate transform function. Something like:
db.select(
isDeleted: item.deletedAt.map(date => date !== null)
).from(item);
db.select(
isDeleted: item.deletedAt.map(date => date !== null)
).from(item);
4 Replies
rphlmr ⚡
rphlmr ⚡5mo ago
Yes you can use partial select and sql operator: https://orm.drizzle.team/docs/select#partial-select
Drizzle ORM - Select
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Tom Sherman
Tom ShermanOP5mo ago
i was ideally looking to do this without using sql and mapWith, i'd prefer to not forfeit the type safety of using those
rphlmr ⚡
rphlmr ⚡5mo ago
I am afraid that’s not possible, except by using the returned value and passing a mapper in the .then/after await. Feel free to open a feature request or comment on https://github.com/drizzle-team/drizzle-orm/discussions/2316
GitHub
Relational API v2 · drizzle-team drizzle-orm · Discussion #2316
We've launched Drizzle Relational Queries exactly a year ago and it's time to ship a fundamental upgrade. We've gathered a massive amount of valuable feedback from the community and goi...
Want results from more Discord servers?
Add your server