Add support for the "@>" operator
starnowski opened this issue · 0 comments
starnowski commented
In PostgreSQL, you can use the @> operator to check if a JSONB object contains another JSONB object. This operator is often used for searching within JSONB arrays or objects. Here's an example:
Let's say you have a JSONB column named json_column with an array of JSONB objects, and you want to check if any of these objects match a certain criteria
-- Sample table
CREATE TABLE my_table (
id serial primary key,
json_column jsonb
);
-- Sample data
INSERT INTO my_table (json_column)
VALUES
('[{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]'),
('[{"name": "Bob", "age": 35}, {"name": "Alice", "age": 28}]');
-- Query to check if a JSONB object in the array matches the criteria
SELECT *
FROM my_table
WHERE json_column @> '[{"name": "Jane", "age": 25}]';