javascript - IndexDB Uncaught Failed to execute 'transaction' on 'IDBDatabase' -
i'm working in login/sigup sistem, have take value of inputs register them, have problem.
the error is: uncaught domexception: failed execute 'transaction' on 'idbdatabase': 1 of specified object stores not found.
and occur in code line: "var data = active.transaction(["usuarios"], "readwrite");"
can me this? here code:
var indexeddb = window.indexeddb || window.mozindexeddb || window.webkitindexeddb || window.msindexeddb; var database = null; function startdb(){ database = indexeddb.open("objectdb", 1); database.onupgradeneeded = function (e) { var active = database.result; var objectdb = active.createobjectstore("usuarios", {keypath: 'id', autoincrement : true }); objectdb.createindex('index_nombre','nombre', {unique : false}); objectdb.createindex('index_user','usuario', {unique : true}); objectdb.createindex('index_correo','email', {unique : true}); objectdb.createindex('index_pass','pass', {unique : false}); }; database.onsuccess = function (e) { alert("base de datos cargada correctamente"); }; database.onerror = function (e) { alert("error cargando la base de datos"); }; } function add() { var active = database.result; var data = active.transaction(["usuarios"], "readwrite"); var objectdb = data.objectstore("usuarios"); var request = objectdb.put({ nombre: document.queryselector("#nombre").value, usuario: document.queryselector("#usuario").value, email: document.queryselector("#email").value, pass: documento.queryselector("#pass").value, }); request.onerror = function (e) { alert(request.error.name + '\n\n' + request.error.message); }; data.oncomplete = function (e) { document.queryselector("#nombre").value = ""; document.queryselector("#usuario").value = ""; document.queryselector("#email").value = ""; document.queryselector("#pass").value = ""; alert("objeto agregado correctamente"); }; }
this first project indexeddb i'm noob. sorry if
i found answer, error in var objectdb, put d in lowercase , worked.
Comments
Post a Comment