indexeddb

IndexedDB - Do errors bubble all the way to IDBOpenDBRequest?

好久不见. 提交于 2020-01-24 22:58:19
问题 I’m using indexedDB for the first time, and the mozilla documentation states that errors bubble all the way to the “database” instance. It’s my understanding that event propagation in this system is entirely inherited from the DOM event model. I’m curious if what is meant is that errors will bubble all the way to IDBOpenDBRequest (that which is instantiated with indexedDB.open()). The documentation states that you can attach an onerror event handler to the top level IDB instances and it can

DOM IDBDatabase Exception 5 when adding data in indexedDB

∥☆過路亽.° 提交于 2020-01-24 15:49:04
问题 My object structure is like this: var test={ "id":"A", "ChanName":"Discovery", "LCN":10 }; This is the snippet that creates the object store: var objectStore = db.createObjectStore('Dat', { keyPath:'test.id',autoIncrement: false}); var trans = db.transaction(["Dat"], webkitIDBTransaction.READ_WRITE); var store = trans.objectStore("Dat"); var request=store.put(test); When i try to add the test object i get this exception DATA_ERR: DOM IDBDatabase Exception 5. Please can you advice on what is

DOM IDBDatabase Exception 5 when adding data in indexedDB

牧云@^-^@ 提交于 2020-01-24 15:48:32
问题 My object structure is like this: var test={ "id":"A", "ChanName":"Discovery", "LCN":10 }; This is the snippet that creates the object store: var objectStore = db.createObjectStore('Dat', { keyPath:'test.id',autoIncrement: false}); var trans = db.transaction(["Dat"], webkitIDBTransaction.READ_WRITE); var store = trans.objectStore("Dat"); var request=store.put(test); When i try to add the test object i get this exception DATA_ERR: DOM IDBDatabase Exception 5. Please can you advice on what is

indexedDB数据库实践

此生再无相见时 提交于 2020-01-19 03:54:16
export default { indexedDB: window.indexedDB || window.webkitindexedDB || window.msIndexedDB, openDb(dbName, version = 1, db, newStore, cb) { const request = this.indexedDB.open(dbName, version); request.onerror = function(e) { console.error("打开数据库错误", e); }; request.onsuccess = function(e) { console.log("打开数据库成功", e); db = e.target.result; if (cb) cb(db); }; // 建表 request.onupgradeneeded = function(e) { var mdb = e.target.result; console.log(mdb); if (!mdb.objectStoreNames.contains(newStore.name)) { const objStore = mdb.createObjectStore(newStore.name, { // keyPath: newStore.key autoIncrement

Querying an IndexedDB compound index with a shorter array

蓝咒 提交于 2020-01-15 12:30:14
问题 IndexedDB allows you to make indexes on multiple properties. Like if you have objects like {a: 0, b: 0} you can make an index on a and b . The behavior of compound indexes is pretty weird, but apparently it is supposed to be possible to query with an array that is shorter than the compound index. So in my example, I should be able to query on something like [0] and get results for a==0. But I can't seem to get that to work. Here's an example which you can run on JS Bin: var db; request =

How do I do an JOIN-type query in IndexedDB

孤者浪人 提交于 2020-01-15 05:55:10
问题 I have tried following the tutorial at http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/ with regards to doing queries in IndexedDB, but their example does not work. How to I do a JOIN type query in IndexedDB? I have set my objectstores up with indexes, but I just cant seem to get the syntax? 回答1: IndexedDB is key-value (document) store. It doesn't have JOIN query or querying over multiple object store. However you can query multiple stores in a transaction. That is how

Lawnchair-IndexedDB doesn't support multiple records

我与影子孤独终老i 提交于 2020-01-15 05:16:06
问题 I tried creating multiple records in indexed-db but it won't allow me, example, nike and adidas objectStores var nike = Lawnchair({adapter:'indexed-db', name:'stores', record:'nike'},function(e){ console.log("nike store open"); this.save({id:1}, function(data){ console.log('nike data: ', data); }); }); var adidas = Lawnchair({adapter:'indexed-db', name:'stores', record:'adidas'},function(e){ console.log("adidas store open"); this.save({id:1}, function(data){ console.log('adidas data: ', data)

How can I put several requests in one transaction in IndexedDB

寵の児 提交于 2020-01-14 12:49:07
问题 My code is like the following: ... var f1 = function(trans) { var store = trans.objectStore('ObjectStore'); store.clear(); }; var f2 = function(trans) { var store = trans.objectStore('ObjectStore'); store.add({id: 1, data: 'text'}); }; ... var trans = DB.connection.transaction(['ObjectStore'], IDBTransaction.READ_WRITE); trans.onerror = function() { alert('ERROR'); }; trans.oncomplete = function() { alert('DONE'); }; ... The problem us that i get the DONE alert right after clear and on the

React - show hide two elements without flickering on page load

删除回忆录丶 提交于 2020-01-14 10:26:14
问题 Edit. I rewrote the code to be even more minimalist. The below code is a spike test of my issue. Here is a video of the issue: https://imgur.com/a/WI2wHMl I have two components. The first component is named TextEditor (and it is a text editor) but its content is irrelevant - the component could be anything. A simple div with text would be just as relevant. The next component is named Workflows and is used to render a collection from IndexDB (using the Dexie.js library). I named this

IndexedDB callback not updating UI in angularjs

拈花ヽ惹草 提交于 2020-01-14 02:44:11
问题 I am using the following library to access IndexedDB in Angularjs on a new Chrome App: https://github.com/aaronpowell/db.js When I try to update the UI on App startup by using this : db.orders.query().all().execute().done(function(results) { $scope.ordercount = results.length; }); in my main.html I have used the ordercount variable as: Orders : {{ordercount}} However, the UI is not updating unless I do ng-click or any other ng-* events. All I need is to show number of orders when my app is