I read a value from database, then based on that value, I read a second one. Here is the code:
mydb.db.get("store1", 1)
.then(function(result1) {
// Assume result1 is needed here.
// This second get() will cause error.
return mydb.db.get("store2", 1);
})
.then(function(result2) {
// Assume result2 is needed here.
});
The problem is, the second get() will cause this error (copied from console output in Chrome):
Uncaught TypeError: Cannot call method 'push' of undefined (in deferred.js:397)
If I remove the return
clause, no error produced but I cannot get the result2.
I am using ydn.db-isw-core-qry.js (production) v0.8.12 with source map, IndexedDB database on Chrome 33.0.1750.149, Windows.
Is there something wrong with my code? Please help.
Thank you.