我使用Rails-4,有產品型號及存儲規格JSON類型Postgres裏的JSON數據類型查詢Rails的4
在遷移文件,添加 add_column :products, :specifications, :json
小樣記錄看像
#<Product id: 1, prod_id: 525141, cat_id: 6716, category_id: 5, updated: "2013-09-24 07:37:20", created_at: "2014-03-07 12:21:34", updated_at: "2014-03-07 12:32:36", eans: ["4016032274001"], skus: ["DK-1511-010F/WH"], account_id: 2, specifications: {"network"=>["PCI-Express 2.1 16x", "CardBus", "PCI-Express 3.0 16x", "PCI 64-bit, 66MHz", "PCI 64-bit, 33MHz", "PCI 32-bit, 66MHz", "PCI 3.0", "PCI 2.3", "PCI 2.2", "PCI-X", "PCI-Express 16x", "PCI-Express 8x", "PCI-Express 4x", "PCI-Express 2.0 16x", "PCI-Express 1x", "PCI", "PC Card", "ISA", "AGP 8x", "AGP 4x", "AGP 2x", "AGP 1x"], "rating"=>[4]}>
我要對產品的Specification.eg查詢:獲取等級(內部規格)所有產品等於4
是否有任何寶石可以實現這個?
這是什麼運氣? –
使用的Serian寶石 - 手動執行。計劃移動彈性搜索而不是手動。 –