storagedb
storagedb copied to clipboard
How to check the existence of DB and Collection
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');