+ let objectStore = db
+ .transaction("games", "readonly")
+ .objectStore("games");
+ let index = objectStore.index("score");
+ const range = IDBKeyRange.only("*");
+ let games = [];
+ index.openCursor(range).onsuccess = function(event) {
+ let cursor = event.target.result;
+ if (!cursor) callback(games);
+ else {
+ // If there is still another cursor to go, keep running this code
+ let g = cursor.value;
+ // Do not retrieve moves or clocks (unused in list mode)
+ g.movesCount = g.moves.length;
+ delete g.moves;
+ delete g.clocks;
+ delete g.initime;
+ games.push(g);
+ cursor.continue();
+ }
+ };
+ });
+ },
+
+ // Retrieve completed local games
+ getNext: function(upperDt, callback) {
+ dbOperation((err,db) => {
+ let objectStore = db
+ .transaction("games", "readonly")
+ .objectStore("games");
+ let index = objectStore.index("created");
+ const range = IDBKeyRange.upperBound(upperDt);