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
bloberenober
bloberenober16mo ago
Check the jsonb examples in the docs
Julio2049
Julio204916mo 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.
bloberenober
bloberenober16mo 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
Julio2049
Julio204916mo ago
Ok. Thanks. The syntax must have changed without my noticing it. I appreciate it.
bloberenober
bloberenober16mo ago
Could you share where did you find the example with the old syntax?
Julio2049
Julio204916mo 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
bloberenober
bloberenober16mo ago
I see - it's a rather old version