The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Using SQLite database with Javascript Reply To: Using SQLite database with Javascript

Ilan Firsov

Trying my luck with IndexedDB.
I can create a database and a table (object store) in it, get data from a json file (exported from the SQLite file), and load said data to a table. Rather simple and not really that slow (and it’s going to happen only on first install or specific upgrades so it’s not that bad :) )
But I just can’t figure out how to create multiple tables/object stores.
Only one of the object stores gets populated. It’s either the last one or the one which I don’t comment out.
Does anyone here have any experience with IndexedDB and can tell what am I doing wrong?

 var request ="myDB", 1);
    request.onupgradeneeded = function (event) {
        var db =;
        var alertAreasObjectStore, citiesDataObjectStore;
        //object store 1
    alertAreasObjectStore = db.createObjectStore("alertareas", { keyPath : "cityAlertId", unique: true });
        alertAreasObjectStore.createIndex("alertAreasAlertAreaIndex", "alertArea", { });
        alertAreasObjectStore.transaction.oncomplete = function(event) {
            var obs = db.transaction("alertareas", "readwrite").objectStore("alertareas");
            //loop - adding data

        //object store 2
    citiesDataObjectStore = db.createObjectStore("cities", { autoIncrement: true });
        citiesDataObjectStore.createIndex("citiesAlertAreaIndex", "alertArea", { });
        citiesDataObjectStore.transaction.oncomplete = function(event) {
            var obs = db.transaction("cities", "readwrite").objectStore("cities");
            //loop - adding data