[IndexedDB] IDBDAtabase.transaction clarification

2012-02-23 Thread João Eiras


Hi.

It seems IDBDatabase.transaction in the working draft is poorly defined.

IDBDatabase.transaction, according to the transaction creation algorithm,
have a null callback, but then IDBDatabase.createObjectStore and
IDBDatabase.deleteObjectStore say they should fail if not called from the
transaction callback. I think it should be changed so they fail if there
is not an active transaction, or that the current active transaction is
not a VERSION_CHANGE one. Is this the intended behavior ?

It tells IDBDatabase.transaction returns the IDBTransaction object.
Shouldn't it be an IDBRequest object ? If not, then what the lifetime of
the transaction ? When should it be commited ?

IDBDatabase.transaction accepts either an array of strings or string as
first argument, which are the name of the object stores. What should
be used for the very first transaction of an empty database with no
object stores ? Empty array ?



Re: [IndexedDB] IDBDAtabase.transaction clarification

2012-02-23 Thread Jonas Sicking
On Thu, Feb 23, 2012 at 9:27 PM, João Eiras jo...@opera.com wrote:

 Hi.

 It seems IDBDatabase.transaction in the working draft is poorly defined.

 IDBDatabase.transaction, according to the transaction creation algorithm,
 have a null callback, but then IDBDatabase.createObjectStore and
 IDBDatabase.deleteObjectStore say they should fail if not called from the
 transaction callback. I think it should be changed so they fail if there
 is not an active transaction, or that the current active transaction is
 not a VERSION_CHANGE one. Is this the intended behavior ?

Yes. Please file a bug.

 It tells IDBDatabase.transaction returns the IDBTransaction object.
 Shouldn't it be an IDBRequest object ? If not, then what the lifetime of
 the transaction ? When should it be commited ?

IDBTransaction is correct.

How committing works should be detailed in the Transaction part of the
Constructs section:

http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#transaction-concept

 IDBDatabase.transaction accepts either an array of strings or string as
 first argument, which are the name of the object stores. What should
 be used for the very first transaction of an empty database with no
 object stores ? Empty array ?

When a database is created a VERSION_CHANGE transaction is
automatically created. So there is no need to call
IDBDatabase.transaction. Not entirely sure I understand the question
here.

/ Jonas



Re: [IndexedDB] IDBDAtabase.transaction clarification

2012-02-23 Thread João Eiras



IDBDatabase.transaction accepts either an array of strings or string as
first argument, which are the name of the object stores. What should
be used for the very first transaction of an empty database with no
object stores ? Empty array ?


When a database is created a VERSION_CHANGE transaction is
automatically created. So there is no need to call
IDBDatabase.transaction. Not entirely sure I understand the question
here.



Then how can one get a reference to that IDBTransaction object ?



Re: [IndexedDB] IDBDAtabase.transaction clarification

2012-02-23 Thread Jonas Sicking
req = indexedDB.open(mydb, 5);
req.onupgradeneeded = function(e) {
  assert(e.target === req);
  var thetransaction = req.transaction;
  var thedb = req.result;
  doStuffWith(thetransaction, thedb);
}
req.onsuccess = function(e) {
  assert(e.target === req);
  assert(req.transaction === null);
  var thedb = req.result;
  alert(the database is now open);
}

/ Jonas

On Thu, Feb 23, 2012 at 10:56 PM, João Eiras jo...@opera.com wrote:

 IDBDatabase.transaction accepts either an array of strings or string as
 first argument, which are the name of the object stores. What should
 be used for the very first transaction of an empty database with no
 object stores ? Empty array ?


 When a database is created a VERSION_CHANGE transaction is
 automatically created. So there is no need to call
 IDBDatabase.transaction. Not entirely sure I understand the question
 here.


 Then how can one get a reference to that IDBTransaction object ?