PostgreSQL – SEQUELize: Query if array contains value

Suppose I have a PG ARRAY field:

id | array |
===|== ===========|
1|{"1","2","3"}|

How to use sequelize to query to see if an array field is a value 1.

I tried:

array: {$contains: "1" }

This gave me:

array @> "1"

There is an error:

Possibly unhandled SequelizeDatabaseError: array value must start with "{" or dimension information

UPDATE

I can do:
Array: {$contains:'{‘value’}’}

Is there a more correct way?

I realize that sequelize expects conditions to be an array:

array: {$contains: ["1"] }

That works. Cheers! !

Suppose I have a PG ARRAY field:

id | array |
== =|=============|
1|{"1","2","3"}|

How to use sequelize query to view array Is the field value 1.

I tried:

array: {$contains: "1" }

This Gave me:

array @> "1"

There is an error:

Possibly unhandled SequelizeDatabaseError: array value must start with "{" or dimension information

UPDATE

I can do:
Array: {$contains:'{‘value’}’}

Is there a more correct way?

I realized that sequelize expects conditions to be an array:

array: {$contains : ["1"] }

That works. Cheers! !

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 702 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.