W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

Re: [Bug 12321] New: Add compound keys to IndexedDB

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Fri, 18 Mar 2011 13:40:30 -0400
Message-ID: <AANLkTi=4Z-pTy8GyDmx9DBM5EPQLPDx=thzvxmwck68y@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: Jeremy Orlow <jorlow@chromium.org>, public-webapps@w3.org
On Fri, Mar 18, 2011 at 12:51 PM, Glenn Maynard <glenn@zewt.org> wrote:
> Most SQL engines (Postgresql, SQLite) support "CREATE INDEX idx ON tbl (date
> DESC, name ASC)" .  This allows "ORDER BY date DESC, name ASC" (eg. "newest
> events first, events per date sorted by name") and its reverse, "name DESC,
> date ASC".  MySQL is an outlier in not supporting this.

In this as in many things.  Nevertheless, in my experience using
MySQL, it's rarely a problem, so solving it in a first pass is perhaps
not essential.  If you're going to solve it, I suggest allowing array
keys to be a dictionary, like

store = db.createObjectStore("mystore", [{col: "firstName", dir:
"asc"}, {col: "lastName", dir: "desc"}]);

where "foo" is equivalent to {col: "foo"} or whatever.  This will be
useful not just for sorting, but for any per-column option in the
index, such as what collation you want to use for text (which is
essential for international sorting).

If this syntax is to be used, though, the current syntax would remain
compatible, so column options can be pushed off to a later version of
the standard.
Received on Friday, 18 March 2011 17:41:23 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:43 GMT