Reputation: 133
In my ionic 3 app I’m storing data in a pouchDB database (6.3.4) using the webSQL adapter. After update to ionic 4 using a new project, I’m trying to access the data in the database. But it is empty. What’s the problem? How can I use the data of my old app?
I use nearly the same code to initialize the database in Ionic 3 and in Ionic 4. But after updating the app on my device there's no document left in the database. The only structural difference is, that in Ionic 4 I'm using a promise:
Imports in both cases:
import PouchDB from 'pouchdb';
import cordovaSqlitePlugin from 'pouchdb-adapter-cordova-sqlite';
PouchDB.plugin(cordovaSqlitePlugin);
Ionic 3:
initDB() {
this.db = new PouchDB('TeacherBook.db', { adapter: 'websql' });
_allData = undefined;
}
Ionic 4:
initDB() {
return new Promise(resolve => {
this.db = new PouchDB('TeacherBook.db', { adapter: 'websql'});
_allData = undefined;
resolve(true);
})
}
I don't know what's the problem. Can you help me, please? Thanks in advance!
Upvotes: 0
Views: 230
Reputation: 883
I am not sure which browser you are using, but in Chrome you can see all the locally stored data in the "Application" tab of the developer tools. There are several reasons why you cannot find your database, perhaps you cleared local data or used the "Clear Storage" option in developer tools, or your application is now hosted at a different location. PouchDb will create a new empty database if it cannot find the existing one.
Upvotes: 0