Re: [IndexedDB] Syntax for opening a cursor

2010-06-28 Thread Nikunj Mehta
Hi Jeremy,

I have been able to push my changes (after more Mercurial server problems) just 
now. I reopened 9790 because Andrei's commit made IDBCursor and IDBObjectStore 
constants unavailable from the global object. After all this, you should be 
able to do the following for your need below:

myObjectStore.openCursor(IDBKeyRange.leftBound(key), 
IDBCursor.NEXT_NO_DUPLICATE);

Nikunj
On Jun 25, 2010, at 4:25 AM, Jeremy Orlow wrote:

 If I'm reading the current spec right (besides the [NoInterfaceObject] 
 attributes that I thought Nikunj was going to remove), if I want to open a 
 cursor, this is what I need to do:
 
 myObjectStore.openCursor(new IDBKeyRange().leftBound(key), new 
 IDBCursor().NEXT_NO_DUPLICATE);
 
 Note that I'm creating 2 objects which get thrown away after using the 
 constructor and constant.  This seems pretty wasteful.
 
 Jonas' proposal (which I guess Nikunj is currently in the middle of 
 implementing?) makes things a bit better:
 
 myObjectStore.openCursor(window.indexedDB.makeLeftBoundedKeyRange(key), new 
 IDBCursor().NEXT_NO_DUPLICATE);
 
 or, when you have a single key that you're looking for, you can use the short 
 hand
 
 myObjectStore.openCursor(key, new IDBCursor().PREV);
 
 But even in these examples, we're creating a needless object.  I believe we 
 could also use the prototype to grab the constant, but the syntax is still 
 pretty verbose and horrid.
 
 Can't we do better?
 
 J



[IndexedDB] Syntax for opening a cursor

2010-06-24 Thread Jeremy Orlow
If I'm reading the current spec right (besides the [NoInterfaceObject]
attributes that I thought Nikunj was going to remove), if I want to open a
cursor, this is what I need to do:

myObjectStore.openCursor(new IDBKeyRange().leftBound(key), new
IDBCursor().NEXT_NO_DUPLICATE);


Note that I'm creating 2 objects which get thrown away after using the
constructor and constant.  This seems pretty wasteful.

Jonas' proposal (which I guess Nikunj is currently in the middle of
implementing?) makes things a bit better:

myObjectStore.openCursor(window.indexedDB.makeLeftBoundedKeyRange(key),
new IDBCursor().NEXT_NO_DUPLICATE);


or, when you have a single key that you're looking for, you can use the
short hand

myObjectStore.openCursor(key, new IDBCursor().PREV);


But even in these examples, we're creating a needless object.  I believe we
could also use the prototype to grab the constant, but the syntax is still
pretty verbose and horrid.

Can't we do better?

J


Re: [IndexedDB] Syntax for opening a cursor

2010-06-24 Thread Tab Atkins Jr.
On Thu, Jun 24, 2010 at 1:25 PM, Jeremy Orlow jor...@chromium.org wrote:
 If I'm reading the current spec right (besides the [NoInterfaceObject]
 attributes that I thought Nikunj was going to remove), if I want to open a
 cursor, this is what I need to do:

 myObjectStore.openCursor(new IDBKeyRange().leftBound(key), new
 IDBCursor().NEXT_NO_DUPLICATE);

 Note that I'm creating 2 objects which get thrown away after using the
 constructor and constant.  This seems pretty wasteful.
 Jonas' proposal (which I guess Nikunj is currently in the middle of
 implementing?) makes things a bit better:

 myObjectStore.openCursor(window.indexedDB.makeLeftBoundedKeyRange(key),
 new IDBCursor().NEXT_NO_DUPLICATE);

 or, when you have a single key that you're looking for, you can use the
 short hand

 myObjectStore.openCursor(key, new IDBCursor().PREV);

 But even in these examples, we're creating a needless object.  I believe we
 could also use the prototype to grab the constant, but the syntax is still
 pretty verbose and horrid.
 Can't we do better?

If we're specifying something that will get wrapped in a library to
make it less horrible *on day 1* (or earlier), we're doing it wrong.

All of the variants above are very, very wrong.

~TJ