Advertisement
Guest User

Clearing namespaces with IDBWrapper

a guest
Feb 27th, 2014
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function clearBranch(branch) {
  2.     if (typeof branch === 'undefined' || branch === null)
  3.         branch = '';
  4.     branch = String(branch);
  5.     var options = {
  6.         onEnd: function() {
  7.             console.log('branch "' + branch + '" cleared');
  8.         },
  9.         writeAccess: true
  10.     };
  11.     if (branch !== '') {
  12.         options.keyRange = idbStore.makeKeyRange({
  13.             lower: branch + '.', // charCode 46
  14.             upper: branch + '/', // charCode 47
  15.             excludeUpper: true
  16.         });
  17.     }
  18.     idbStore.iterate(function(item, cursor) {
  19.         cursor.delete();
  20.     }, options);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement