Tag: indexeddb

Local DB API – deprecated what is the alternative?

The local DB api based on SQLite is going down. According to w3c it has to be replaced indexedDB. But IndexedDB API is still work in progress so no implementation yet. For an app that needs massive db storage… and for the time being; what is the alternative? What would be the most future proof? […]

Using IndexedDB to save images

The line of code is <img src=”picture_1.png” id=”imgHolder”/> I would like to save the image in indexedDB in a database named Images on a button click. <button id=”write” onclick=”saveToDB()”>Save To DB</button> When I click another button, I must be able to read the image from database named Images and display in a <div id=”resultContent”/>. <button […]

IndexedDB and Javascript: JSON and objects misunderstanding

I’m trying to obtain information from a JSON file download to the client through AJAX and I’m getting different results depending on the JSON format and I don’t know how to fix the one with problem. First case: The json files looks like: [{“name”: “nick”, “age”: 28}, {“name”: “katie”, “age”: 32}] My AJAX .done method […]

How to retrieve IndexedDB table data to variable?

I have some data in a IndexedDB table that quite simply contains this data: var Customers = [ { ssn: “123-45-6666”, name: “Andrew”, age: 22, email: “andrew@hotmail.com” }, { ssn: “555-66-7777”, name: “Gail”, age: 25, email: “gail@email.me” } ]; I then have this function to get data back from the IndexedDB: function RetrieveTableRows(Table) { var […]

Is there a way to execute a function when user tries to delete an indexedDB database?

Is there anything like ondelete event handler, or way to warn user before they want to clear the indexedDB database. Background: There is a offline first app, that works by saving most of the data on indexedDB while offline. Now, when the user goes online, it tries to sync the data to the server, but, […]

IndexedDB Fails when adding objects that contain element references

I’m writing an application for Google Chrome (targeted audience is an internal team) that allows a user to manipulate elements from within an iframe. The user is able to use her mouse to select DOM elements and to perform various actions to them, such as changing colors, fonts, etc. I’m using a nodeIterator method to […]

IndexedDB.open callbacks not called on Chrome

I am trying to use IndexedDB, and everything was working well, up until a few hours ago when my .open() callbacks stopped being called on Chrome (tested on Safari and it worked fine). RT.prototype.setupIndexedDB = function (callback) { var dbName = “test”; var dbVersion = 1; var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB; console.log(“setup […]

How to simulating the aggregate functions avg, sum, max, min, and count on PouchDB?

Does anyone know how to create aggregate functions, for example avg, sum, max and min on PouchDB database. I created a simple application to test the PouchDB. I’m still not figured out how to run these commands. Thanks in advance. For example. How do you get the highest, lowest or average for the “number” field? […]

Adding an index to an existing object store in IndexedDB

How do I add an index to a previously created object store, within the upgrade needed event? Doing this on a new object store is well documented: request.onupgradeneeded = function(event) { var db = event.target.result; var objectStore = db.createObjectStore(“my-store”, { keyPath: “id” } ); objectStore.createIndex(“idx_name”, “index_this”, { unique: false }); }; But how can I […]

Should I open an IDBDatabase each time or keep one instance open?

I have a SPA application that will make multiple reads/writes to IndexedDB. Opening the DB is an asynchronous operation with a callback: var db; var request = window.indexedDB.open(“MyDB”, 2); request.onupgradeneeded = function(event) { // Upgrade to latest version… } request.onerror = function(event) { // Uh oh… } request.onsuccess = function(event) { // DB open, now […]