indexeddb

How to return indexedDB query result out of event handler?

大憨熊 提交于 2019-12-24 00:33:29
问题 I have to return query result from indexedDB, but the result is only available in onsuccess event handler. 1 function listPeople(){ ... 4 var open = indexedDB.open("AccordionDatabase",1), 5 res; 6 7 open.onsuccess = function(){ 8 var db = open.result; 9 var transaction = db.transaction("PeopleStore", "readwrite"); 10 var store = transaction.objectStore("PeopleStore"); 11 var request = store.getAll(); 12 request.onsuccess = function(event){ 13 res = event.target.result; 14 console.log(res); 15

How to add a new Objectstore to an existing indexeddb

允我心安 提交于 2019-12-23 20:16:13
问题 Can anybody tell me how to add a new objectstore to an existing indexeddb instance which has a version number in it. When I try to create a new version existing object stores are getting deleted. I have a version '1', which has around 10 object stores with data. When I try to open the same database with new version number, I lost the current data and object stores. here is what I have tried. var _upRequest = indexedDB.open("employees"); _upRequest.onsuccess = function (e) { var thisDb = e

Most efficient way to populate/distribute indexedDB [datastore] with 350000 records

落花浮王杯 提交于 2019-12-23 19:15:03
问题 So, I have a main indexedDB objectstore with around 30.000 records on which I have to run full text search queries. Doing this with the ydn fts plugin this generates a second objectstore with around 300.000 records. Now, as generating this 'index' datastore takes quite long I figured it had be faster to distribute the content of the index as well. This in turn generated a zip file of around 7MB which after decompressing on the client side gives more than 40MB of data. Currently I loop over

indexedDB doesn't reset version when you delete a database on Chrome — bug or user error?

房东的猫 提交于 2019-12-23 17:31:31
问题 The following code throws an error in Chrome 35 (but not Firefox 29) if I set buggy to true . Since I'm pretty new in indexedDB I wanted to ask whether this ought to work or not. If I delete the database and open it again with version=1 , shouldn't my onupgradeneeded callback get called? <html> <head> <script type="text/javascript"> var i = 1000; var buggy = true; function open() { var version = buggy ? 1 : 1001 - i; var request = indexedDB.open("test", version); var upgraded = false; request

IndexedDB slow when inserting

坚强是说给别人听的谎言 提交于 2019-12-23 15:29:56
问题 I installed iOS 8 on a third generation iPad and tried IndexedDB in Safari. My sample code just adds 1000 objects to an object store. It works however it is very slow compared to other devices with similar or weaker hardware. See this snippet for implementation details (IndexedDB seems to be disabled on stackoverflow so the example does not work out of the box - use this fiddle instead ): Added the snippet to jsbin because jsfiddle raises a SecurityException on iOS device and updated with

HTML5 How to tell when IndexedDB cursor is at end

懵懂的女人 提交于 2019-12-23 13:13:06
问题 I am iterating thru an indexedDB data store, adding data to a JavaScript array. How can I tell when the cursor is at the end, so I can sort the array and act on it? onsuccess is called when a row has been retrieved from the cursor - is there another callback when the entire cursor has been navigated? 回答1: The result ( event.target.result ) of a successful cursor request is either a cursor object or null. If event.target.result is set, it's the cursor, and you can access event.target.result

Why does onsuccess sometimes get called before onupgradeneeded when connecting to indexedDB?

▼魔方 西西 提交于 2019-12-23 12:28:05
问题 I am having trouble with IndexedDB. On Firefox 18, when I create a new database, the onsuccess method is called at the same time has onupgradeneeded . On Chrome 24 (this is the behavior I'd like to get), the onsuccess method is only called after the onupgradeneeded method has completed. According to the MDN information on IndexedDB, I was under the impression that when the onsuccess method was called, it was safe to work with the database but this make it seems like it is not in Firefox.

Access Web Storage or IndexedDB from outside the browser in Android

狂风中的少年 提交于 2019-12-23 09:48:55
问题 I want to build an offline browser-based app using HTML and javascript to collect survey data on Android tablets. The app would consist of some static pages with forms for users to enter data, which would then be stored locally using Web Storage or IndexedDB. However, I also want to build a small native Android app which would grab this data and transfer it to other devices. Is this possible, and if so how would I go about it? Specifically, I want to understand if and how the native app would

DataError when creating an index with a compound key in IE 10

懵懂的女人 提交于 2019-12-23 08:51:28
问题 I am testing an indexedDB based app using IE10. I am not able to create an object store which has multiple keys. For example, var objectStore = theDb.createObjectStore("store1", { keyPath: ["key1","key2"] }); . When I try to insert data into the store an exception message is raised: "DataError" This is not very helpful! Has anyone been able to create objectStores using IE10 with multiple keys? This works fine testing in Chrome. 回答1: I run into the same problem. From their forum thread,

Is it possible for a Chrome extension to access an IndexedDB database created by a specific domain?

随声附和 提交于 2019-12-23 07:49:17
问题 If http://example.com/ creates an IndexedDB database, is it possible for a Chrome extension (used on domains other than example.com ) to open and query this database? 回答1: No, you can not do it. The data storage is sandboxed http://www.html5rocks.com/en/tutorials/offline/storage/ 来源: https://stackoverflow.com/questions/13453418/is-it-possible-for-a-chrome-extension-to-access-an-indexeddb-database-created-by