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

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 UTC