working with JSONB in Postgres is painful.
It's powerful, I love that it's there, but actually using it is always such a chore.
It's powerful, I love that it's there, but actually using it is always such a chore.
SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @> '{"tags": ["qui"]}';
or
SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @? '$.tags[*] ? (@ == "qui")';
which find documents in which the key "tags" contains array element "qui"
db.api.find(
{ "tags": "qui" },
{
"guid": 1,
"name": 1,
"_id": 0
}
)