drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: transform/alias raw row properties

Open
#2,392 4 comments 4 reactions 0 assignees View on GitHub
enhancement qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Describe what you want

Hello, i'm currently using drizzle, but must rely on native `postgres-js` for features not currently supported by drizzle (e.g. triggers/function, publications, subscriptions).

While this works kinda fine, an issue i frequently face is the lack of transformation with this raw postgres usage.

Let assume i have a users table with: `lastName: text(last_name)`
When fetching data via drizzle `last_name` would be aliased to `lastName` and i can access the property via `value.lastName` on the result.

When i do e.g. a subscription via raw postgres-js
```
await client.subscribe("insert:users", (row) => {
console.log(row.last_name); // <-- unaliased
});
```
the row properties will be unaliased and all the helper functions i built around the drizzle types will break.

Does drizzle somehow expose this transform / alias? I couldn't find anything on the docs.

I imagine a `schema.transformToAliased(rawValue)` to map from unaliased to aliased object properties would be quite helpful to workaround shortcomings on more complex db functionality not currently supported by drizzle.

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.