Search an array using massivejs

371 views Asked by At

I'm trying to construct a query on an array using massivejs, but it keeps telling me the operator is unsupported.

This query works:

SELECT * FROM my_table WHERE data->'items' @> '[{"foo": "bar"}]';

where data is a jsonb field and items is an array of objects. My massivejs query is:

{ 'data #>> {items} @>': '[{ \"foo\": \"bar\" }]' }

but massive tells me the @> operator doesn't exist.

I realize I can execute raw SQL, but I'm building up a query with paging, sorting, and other query conditions, so I'd rather not rebuild all that if I can avoid it.

Is there a mistake in my query? Is this something massivejs even supports?

1

There are 1 answers

1
Valentin Roudge On

I don't think massivejs supports jsonb operators.

Your query is SQL-correct. And I guess that you'll have to do raw SQL on this one.

I just read the API docs and it goes in my direction but I might be overlooking something.