Querying hstore with exists?

619 views Asked by At

I have a column as postgres hstore, and want to query it with exists? in my model.

I am using

Model.where("column ? :key", key: "xxx").count

but effectively I just want to know if there at least one with that key, something like

Contact.exists?("column? :key", key: "xxx")

which results an error, because exists? has on argument only.

Any hints?

Thanks so far.

1

There are 1 answers

0
Luiz Marques On BEST ANSWER

Figured out, simply:

Model.where("column ? :key", key: "xxx").exists?

results in a query with LIMIT 1.