yathit / ydn-db

Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction.
Apache License 2.0
503 stars 41 forks source link

Request to implicitly create a new store with autoSchema is never triggered #87

Open mehdirande opened 9 years ago

mehdirande commented 9 years ago

I have a very strange behaviour with autoSchema. I might have miss something in the documentation or with this option usage but whenever I implicitly create a store (after the first one) by putting a value inside, the deferred request never end :

var db = new ydn.db.Storage('newDatabase', null, {autoSchema: true});
db.put('firstStore', {value: 'dummy'}, 1).always(function() { 
  console.log('Ok');
  return db.put('firstStore', {value: 'still dummy'}, 2);
}).always(function() {
  console.log('Still Ok');
  return db.put('secondStore', {value: 'Too much dummy'}, 1);
}).always(function() {
  console.log('Will not be displayed');
});

If I take a look at my indexed db, secondStore is created but empty. Even strager, if I add

db.put('firstStore', {value: 'no more dummy please'}, 3);

or

db.put('secondStore', {value: 'no more dummy please'}, 2);

The put in 'secondStore' is triggered and 'Will not be displayed' is printed.

Could you help me to find what i'm doing wrong ?

yathit commented 9 years ago

I think you are doing right.

I never use autoSchema in my app, so do not test extensively. Auto schema, which is possible and easier to use, but require disconnect and reconnect the database connection. I can imagine some callback are lost during the process.

When I have time, I will create a unit test and fix it.

mehdirande commented 9 years ago

Thanks a lot, first time i'm using this option too.

cepm-nate commented 4 years ago

@yathit are you still around? I'm curious if anyone's made progress on this?