我想對從索引數據庫獲得的結果進行排序。
每條記錄都有結構{id,text,date},其中'id'是keyPath。排序索引數據庫查詢的結果
我想按日期排序結果。
我當前的代碼是如下:
var trans = db.transaction(['msgs'], IDBTransaction.READ);
var store = trans.objectStore('msgs');
// Get everything in the store;
var keyRange = IDBKeyRange.lowerBound("");
var cursorRequest = store.openCursor(keyRange);
cursorRequest.onsuccess = function(e) {
var result = e.target.result;
if(!!result == false){
return;
}
console.log(result.value);
result.continue();
};
-where是您的SQL查詢 - 對不起? ,我的錯 - 我想到了WebSQL! – Oliver 2012-07-15 12:54:28
請參閱http://stackoverflow.com/questions/12084177/in-indexeddb-is-there-a-way-to-make-a-sorted-compound-query/15625231#15625231 總之,使用一組鍵作爲索引。 – 173210 2016-03-27 02:15:24