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