Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: transform/alias raw row properties #2392

Open
sakulstra opened this issue May 29, 2024 · 1 comment
Open

[FEATURE]: transform/alias raw row properties #2392

sakulstra opened this issue May 29, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@sakulstra
Copy link

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.

@sakulstra sakulstra added the enhancement New feature or request label May 29, 2024
@sakulstra sakulstra changed the title [FEATURE]: transform/alias raw result [FEATURE]: transform/alias raw row properties May 29, 2024
@HarrisonJackson
Copy link

This happens using supabase frequently.

I want to use supabase realtime but the events from it send back the raw rows. It would be great if I could run them through some helper function from drizzle so the typings match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants