我想改變的WebSQL到IndexedDB的。然而,人們會怎麼做SQL查詢,如的Javascript:搜索IndexedDB的使用多個索引
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = '[email protected]@company.com'
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = '[email protected]@company.com' and age = 30
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = '[email protected]@company.com' and name = 'Bill'
etc
與IndexedDB的? 例如,我在閱讀indexedDb的documentation時注意到,所有示例僅在當時查詢一個索引。所以你可以做
var index = objectStore.index("ssn");
index.get("444-44-4444").onsuccess = function(event) {
alert("Name is " + event.target.result.name);
};
但我需要同時查詢多個索引!
我也發現了一些有趣的職位約compound indexes,但他們只如果查詢的複合索引的所有字段工作。
的可能重複的[在索引資料,有一種方法,使已排序的化合物查詢?(http://stackoverflow.com/questions/12084177/in-indexeddb-is-there-a-way-to-make -a-sorted-compound-query) – Josh 2014-05-22 19:15:45