I am using postgress-9.3 with Rails 4.
I have a data type array of hstore(HSTORE[]).
Please see the normal query on product table.
SELECT id, specifications FROM "products" limit 10;
id | specifications
----+----------------------------------------------------------------------------------------------------------
1 | {"\"1368\"=>\"1\"","\"1368\"=>\"0.5\"", "\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
2 | {"\"1368\"=>\"0.46\""}
3 | {"\"1368\"=>\"1.5\""}
4 | {"\"1368\"=>\"5\""}
5 | {"\"1368\"=>\"3\""}
6 | {"\"1368\"=>\"2\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
7 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
8 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
9 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
10 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
My requirement is to Query on product table based on specification values, eg: Lists all product based on condition that 1368(KEY in HSTORE[]) is less than 1(VALUE in HSTORE[]).
# the result should
id | specifications
----+----------------------------------------------------------------------------------------------------------
1 | {"\"1368\"=>\"1\"","\"1368\"=>\"0.5\"", "\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
2 | {"\"1368\"=>\"0.46\""}
7 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
8 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
9 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
10 | {"\"1368\"=>\"0.25\"","\"1371\"=>\"male/male\"","\"1370\"=>\"LAN (RJ-45)\"","\"1369\"=>\"LAN (RJ-45)\""}
How to implement this ?