From 1395597e615dce174f454251ed4e462edd529659 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 4 May 2016 22:30:37 +0200 Subject: [PATCH] increase verbosity + only execute callback during update if defined --- idb.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/idb.js b/idb.js index 20d5ea4..2e4c9e9 100644 --- a/idb.js +++ b/idb.js @@ -25,7 +25,8 @@ var idb = { var store=idb.stores[sn] var key={}; key[store['keytype']]=store['keyname']; - cl("idb: creating store '"+sn+"'"); + cl("idb: creating store '"+sn+"' ("+ + store.keytype+": "+store.keyname+")"); store.os=idb.handle.createObjectStore(sn,key); // indices if(store.idx!==undefined) { @@ -87,6 +88,7 @@ var idb = { idb.successcb=successcb; if(upgradecb!==undefined) idb.onupgradeneeded=upgradecb; + cl("idb: init database '"+idb.name+"'"); var req=indexedDB.open(idb.name,idb.version); req.onsuccess=idb.onsuccess; req.onupgradeneeded=idb.onupgradeneeded; @@ -165,7 +167,8 @@ var idb = { var res=cursor.update(nitem); res.onsuccess=function(event) { cl("idb: updated cursor"); - callback(event); + if(callback!==undefined) + callback(event); }; res.onerror=function(error) { cl("idb: cursor update error"); @@ -177,7 +180,8 @@ var idb = { var addreq=store.add(nitem,num); addreq.onsuccess=function(event) { cl("idb: added (update mode) key "+num); - callback(event); + if(callback!==undefined) + callback(event); } addreq.onerror=function(error) { cl("idb: error add (update mode)"); -- 2.39.2