0

I am using ydn.db from local storage.

Which function can be used to remove the store using YDB.DB library ?
The stores i have added is as follows

var schema = {
  stores: [{
      name:'consignments',
    keyPath:"timeStamp"
    }];

var db = new ydn.db.Storage('localhost', schema);

I wish to check whether the store exist in localstorage and if it exists delete the store and if not exist add the store.

Marc B
  • 356,200
  • 43
  • 426
  • 500
Tej Patil
  • 115
  • 11

2 Answers2

0

If store exist or not can be known only after opening the database. If a schema does not a store name, but exit in the connected database, the existing store will be removed.

To delete the database

var db = new ydn.db.Storage('localhost', schema);

To delete above the database,

ydn.db.deleteDatabase(db.getName(), db.getType());

If type of database is not known

ydn.db.deleteDatabase('localhost');
Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
-1

I use the deleteDatabase function like this:

indexedDB.deleteDatabase(storage_name);

see the doc here: https://dev.yathit.com/api/ydn/db/index.html

johnnyRose
  • 7,310
  • 17
  • 40
  • 61
mca
  • 85
  • 1
  • 9