I have a PostgreSQL table table with a column column containing JSONB data like this:
{
"foo": "abc",
"bar": "123",
"baz": [
"a=1",
"a=2",
"b=5",
"c=1"
],
}
I set up PostgREST.
How can I filter for records that have the string a=1 or the string b=5 but not the string c=1 in the baz array inside the JSONB column?
https://postgrest.org/en/stable/references/api/tables_views.html#json-columns is very sparse on JSON columns.
I thought it was
/table?select=id&column->>baz=cs.{"a=1","b=1"}&column->>baz=not.cs.{"c=1"}
but that gives me
{
"code":"42883",
"details":null,
"hint":"No operator matches the given name and argument types. You might need to add explicit type casts.",
"message":"operator does not exist: text @> unknown"
}
Apparently that was one filter too few (looks like that was a logical OR) and one angle bracket too many: