Short answer:
collection.query('where', 'data', '@>', '{"team": "PSG"}');
Explanation:
Say you have a foos table where the element foo is
------------------------ | id | attr | ------------------------ | 0 |{ "bar": "fooBar"} | ------------------------ | 1 |{ "bar": "fooFoo"} | ------------------------
A raw request for this will be similar.
select * from "foos" where "attr" @> '{"bar":"fooBar"}';
Now in the Bookshelf, if you have a Foo model representing the foos table, it should look similar.
Foo.where('attr', '@>', '{"bar":"fooBar"}').fetch().then(function(rows){});
Now for your case it should be like
collection.query('where', 'data', '@>', '{"team": "PSG"}');
I hope Zlatan approves of this.
source share