-
Notifications
You must be signed in to change notification settings - Fork 326
-
I know it's possible to create a transform so that undefined values are changed into null values for mutative queries such as insert, update.
What I just realized is that it doesn't work the other way around! So when I issue a select query that returns null values, the resulting object contains null values instead of undefined.
How can I transform from null to undefined?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
I found a way to do this... It appears to work but additional feedback appreciated:
export const sql = postgres(
"CONNECTION_STRING",
{
transform:
{
...postgres.camel,
undefined: null,
value:
{
from: value => value === null ? undefined : value
}
}
});
I have a couple of questions/suggestions: could there be an option such as null: undefined to be the counterpoint to undefined: null? Additionally, why is there no to option under value? I can't see why someone would only want to transform data in one direction.
Thank you
Beta Was this translation helpful? Give feedback.