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

[IndexedDB] Multientry and duplicate elements

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 2 Mar 2012 05:29:14 +0100
Message-ID: <CA+c2ei-GXrK5RX-S+3yPhEtxv32wnJOTpnOEQ_FHSg=tM2Ajfw@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
Hi All,

What should we do if an array which is used for a multiEntry index
contains multiple entries with the same value? I.e. consider the
following code:

store = db.createObjectStore("store");
index1 = store.createIndex("index1", "a", { multiEntry: true });
index2 = store.createIndex("index2", "b", { multiEntry: true, unique: true });
store.add({ a: ["x", "x"]}, 1);
store.add({ b: ["y", "y"]}, 2);

Does either of these adds fail? It seems clear that the first add
should not fail since it doesn't add any explicit constraints. But you
could somewhat make an argument that that the second add should fail
since the two entries would collide. The spec is very vague on this
issue right now.

However the first add really couldn't add two entries to index1 since
that would produce two entries with the same key and primaryKey. I.e.
there would be no way to distinguish them.

Hence it seems to me that the second add shouldn't attempt to add two
entries either, and so the second add should succeed.

This is how Firefox currently behave. I.e. the above code results in
the objectStore containing two entries, and each of the indexes
containing one.

If this sounds ok to people I'll make this more explicit in the spec.

/ Jonas
Received on Friday, 2 March 2012 04:30:11 GMT

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