Question: Querying hstore with exists?

Question

Querying hstore with exists?

Answers 1
Added at 2017-01-04 14:01
Tags
Question

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.

Answers
nr: #1 dodano: 2017-01-04 15:01

Figured out, simply:

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

results in a query with LIMIT 1.

Source Show
◀ Wstecz