javascript - Asking for help with a question about indexedDB
某草草
某草草 2017-06-05 11:13:09
0
2
609

As shown below, the primary key of a piece of data I stored is timeStamp. What I know is that this data can be found by getting the primary key value, but cannot the data be retrieved by querying other values in it? Can query conditions similar to SQL statements not be implemented? (Find them all and then iterate through the results to eliminate them)

db.createObjectStore('book', { keyPath: "timeStamp" }); store.get(1496251171844)

Some people say to use an index, but the index cannot be queried based on the value. I still need to make a judgment. What I
want is to directly store.get(group) to get the specified object storage. group

var book = db.createObjectStore('book', { keyPath: "timeStamp" }); // 建立索引 book.createIndex("groupId","groupId", {unique:false}); -------------------------------------------------------- html5.indexedDB.getFromId = function(groud, callback){ var db = html5rocks.indexedDB.db; var tx = db.transaction(['book'],'readwrite'); var store = tx.objectStore('book'); var index = store.index("groupId"); request = index.openCursor(); request.onsuccess = function(event){ var result = event.target.result; if(!result){return;} if(result.value.groupId == groud){ callback(result.value); } result.continue(); }; };
某草草
某草草

reply all (2)
伊谢尔伦

createIndex can add multiple indexes and set whether the index value is unique

    为情所困

    indexedDB is similar to nosql, it can only rely on keyword indexing, and there is no way to query by sql. After obtaining the collection, you can use js method to search.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!