G O A T
DTDrizzle Team
•Created by G O A T on 11/1/2023 in #help
How to Access an array of strings in jsonb format
I am trying to find records where slug (predefined variable) is found in an array in my jsonb players column. The value looks like this:
['John', 'James', 'Joe', 'Jack']
If slug = John then this should return the record.
My below query does not work:
const result = await db.execute(
sql
SELECT * FROM ${table} WHERE ${table.players}::jsonb ? ${slug}
);
I get this error:
ERROR: operator does not exist: jsonb ? record
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
Any suggestions would be really helpful1 replies