storagedb icon indicating copy to clipboard operation
storagedb copied to clipboard

How to check the existence of DB and Collection

Open sarankup opened this issue 6 years ago • 0 comments

Hi,

I want to check whether DB and Collection already exists before I create them. Please advise how to achieve.

I want to check whether DB exists before I create it

const localStorageObj = new StorageDB({
    storage: window.localStorage,     // storage object, default is window.localStorage. If you want to store data in memory only, you can set it null
    database: localStorage.getItem('appkey'),               // database name, default is 'db'
    primaryKey: 'id'                  // primary key of collection, default is '_id'
});

I want to check whether the collection is exists before create it const UsercommentsTable = localStorageObj.get('UsercommentsTable');

sarankup avatar Jul 22 '18 14:07 sarankup