0

I'm not having any luck querying a jsonb[] column (attributes). I couldn't find anything in the Postgresql docs about arrays of jsonb

My data in the column is a bunch of objects in an array like this:

1 - [{ "trait_type": "color", "value": "blue" },{ "trait_type": "hair", "value": "short" }]
2 - [{ "trait_type": "color", "value": "red" },{ "trait_type": "hair", "value": "short" }]
3 - [{ "trait_type": "color", "value": "green" },{ "trait_type": "hair", "value": "long" }]
4 - [{ "trait_type": "color", "value": "blue" },{ "trait_type": "hair", "value": "med" }]

I tried this: SELECT * FROM public.items WHERE attributes @> '[{ "trait_type": "color", "value": "blue" }]';

...but get error: Failed to run sql query: malformed array literal: "[{ "trait_type": "color", "value": "blue" }]"

I also tried: SELECT * FROM public.items WHERE attributes @> ARRAY['{ "trait_type": "color", "value": "blue" }'];

...but get error: Failed to run sql query: operator does not exist: jsonb[] @> text[]

Ken White
  • 123,280
  • 14
  • 225
  • 444
jinsley8
  • 81
  • 5

0 Answers0