javascript - How do I do an JOIN-type query in IndexedDB -
i have tried following tutorial @ http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/ regards doing queries in indexeddb, example not work.
how join type query in indexeddb? have set objectstores indexes, cant seem syntax?
indexeddb key-value (document) store. doesn't have join query or querying on multiple object store. can query multiple stores in transaction. how suppose make join query in indexeddb.
i have bit of writeup modeling relationship http://dev.yathit.com/ydn-db/schema.html using library.
here joining query select * supplier, part supplier.city = part.city
.
var iter_supplier = new ydn.db.indexvalueiterator('supplier', 'city'); var iter_part = new ydn.db.indexvalueiterator('part', 'city'); var req = db.scan(function(keys, values) { var sid = keys[0]; var pid = keys[1]; console.log(sid, pid); if (!sid || !pid) { return []; // done } var cmp = ydn.db.cmp(sid, pid); // compare keys if (cmp == 0) { console.log(values[0], values[1]); return [true, true]; // advance both } else if (cmp == 1) { return [undefined, sid]; // jump pid cursor match sid } else { return [pid, undefined]; // jump sid cursor match pid } }, [iter_supplier, iter_part]);
see more detail on join query article.
Comments
Post a Comment