Open sakulstra opened 1 month ago
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.
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 drizzlelast_name
would be aliased tolastName
and i can access the property viavalue.lastName
on the result.When i do e.g. a subscription via raw postgres-js
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.