1

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.

rahmadid
  • 11
  • 2

1 Answers1

0

Here is test http://dev.yathit.com/test/issue_107.html as you described. No error. Please show your code that cause your error.

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
  • 1
    Hi, I know the cause of the error. It seems that I am using the older version of ydn.db library (I got it from http://dev.yathit.com/index/downloads.html). I confirmed this by testing using your version of ydn.db (from the file issue_107.html above). My code runs fine after I switch the library. Note that my older version still has Storage.onReady(), while the new one does not (the new one uses Storage.addEventListener("ready", ..) ). So, where can I download the newest, stable production version? Thank you very much for your support :) – rahmadid Mar 13 '14 at 17:13
  • Welcome. I will rebuild new release with fix to some pending issues. – Kyaw Tun Mar 14 '14 at 00:44