samedi 25 avril 2015

Querying any member of a Postgres array type in Rails 4


Everywhere I looked there were 2 examples

either

Book.where("'history' = ANY (subjects)")

to query a book with a specific subject in the subject array

or

 Book.where("subjects @> ?", '{'history', 'drama'}')

to query books that the subjects array has both history and drama

How do I query for books that has either history or drama or both?


Aucun commentaire:

Enregistrer un commentaire