jsonb field definition.

What's the right way to define a jsonb field? I have a type type MetaData = {keywords?: string[];} and a field meta: jsonb<MetaData>("meta"), but I'm getting the typescript warnings Type 'PgJsonbBuilderInitial<MetaData>' is not assignable to type 'AnyPgColumnBuilder'.ts(2322) on the lhs and Type 'MetaData' does not satisfy the constraint 'string'.ts(2344) on the rhs. Thanks in advance.
7 Replies
Dan
Dan2y ago
Check the jsonb examples in the docs
Julio Barros
Julio BarrosOP2y ago
Thanks for the response. @bloberenober Do you have a pointer to the docs that you think would be helpful? I looked in the md files in the repo and see some examples such as jsonb: jsonb<string[]>('jsonb') but no clear discussion (that I can understand) on what to do or what could be causing the does not satisfy the constraint error that I get.
Dan
Dan2y ago
It's an outdated version - could you share where did you find this example? Here's an example with the correct syntax - https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/README.md#column-types
Julio Barros
Julio BarrosOP2y ago
Ok. Thanks. The syntax must have changed without my noticing it. I appreciate it.
Dan
Dan2y ago
Could you share where did you find the example with the old syntax?
Julio Barros
Julio BarrosOP2y ago
I had it working with the old syntax before the latest update so I must have originally found it in drizzle-orm-pg 0.15.1
Dan
Dan2y ago
I see - it's a rather old version
Want results from more Discord servers?
Add your server