indexing - Select from IndexedDB database, using multiple indexes -
each of indexeddb objects have following format:
object: { objectname: "somename" objecttest: "sometest" objectage: "someage" }
then have following indexes set:
storeobject.createindex( "by_objectname", "objectname", { unique: false } ); storeobject.createindex( "by_objecttest", "objecttest", { unique: false } ); storeobject.createindex( "by_objectage", "objectage", { unique: false } );
so first wanted loop through objects objectname (this working):
var openedindex = storeobject.index("by_objectname"); var numitemsinindex = openedindex.count(); if (openedindex) { var curcursor = openedindex.opencursor(); curcursor.onsuccess = function(evt) { var cursor = evt.target.result; if (cursor) { //do cursor.continue(); } } }
so above code taking objects , sorted objectname. how can take objects have objecttest: "certainvalue"
, sorting objectname remain same in above example. need filter list of result before line if (openedindex) {
because need use numitemsinindex
later in loop.
so in other words, if relational database, how implement:
select * objects objecttest = "certainvalue" sort objectname
you can create index on 2 properties @ once defining keypath parameter createindex array. use property wish sort first item in array. example, see other posts, one: in indexeddb, there way make sorted compound query?
Comments
Post a Comment