drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Option to pass reviver to JSON.parse
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
I'm trying to create a custom type to revive some of my JSON. But when the value of the jsonb column gets to the fromDriver hook, it is already an object, meaning the JSON.parse is happening someplace else.
```
export const jsonb = (name: string) =>
customType({
dataType() {
return "jsonb"
},
toDriver(value) {
return JSON.stringify(value)
},
fromDriver(value) {
console.log(typeof value)
return value
},
})(name)
```
While I can still solve my specific problem doing the revive work here, It would be nice to have an option to pass the JSON.parse implementation we desire. Something like:
```
const client = drizzle(
connection,
debug ? { logger: new DefaultLogger({ writer: new ConsoleLogWriter() }) } : undefined,
stringifyJson: undefined,
parseJson: (value) => {
return JSON.parse(value)
},
)
```
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.