I am trying make a function that returns an array of all the objects in an object store. This is the JavaScript code I currently have:
function readAllSessions() {
var output = [];
database.transaction("practiceSessions").objectStore("practiceSessions").openCursor().onsuccess = function (e) {
var cursor = e.target.result;
if (cursor) {
output.push(cursor.value);
cursor.continue();
}
}
return output;
}
This returns an empty array. I found that the cursor object is null, but I can't see why, since there are 3 objects in the object store.