Hello,
Currently i’m building an app using sqlite, and i wanted to use an ORM, so i found a github repository that integrate sqlite and TypeOrm with ionic and capacitor, it does the job perfectly but i recenlty i found 2 problems that i need help to solve :
The first problem is when i build the app in production mode i got this error
In the sqlite database i see that all migarations are OK with the correct names of the tables, but in the query it always change the table name with B- C …
Note that in dev mode i didnt get this kind of error either on an iOS simulator or my iphone test device
The second problem, is a bit random, occasionally, I got an error message stating that the connection to the database is not available, as shown in screenshot below:
Sometimes i got this error when the app starts, or when i return to the home page(where the sqlite database is initialized) so the only turn around is to quit the app and launch it again:
Here is ngOninit for the home page
async ngOnInit(): Promise<void> {
try {
await this.initOrmService();
console.log("*** ORM service has been initialized ***");
this.platform = this.offlineEdlService.platform;
await Promise.all([
this.getOfflineProperties(),
this.getSyncedProperties(),
this.getConnectedUser()
]);
if (!this.ormService.isOrmService) {
throw new Error(`Error: TypeOrm Service didn't start`);
}
} catch (error) {
console.log('Database initialization error:', error);
}
this.checkLoggedIn();
this.defaultInventories = await this.offlineEdlService.saveDefaultInventory();
await this.offlineEdlService.saveSearchableInventory();
await this.fetchAgentApartments();
}
async initOrmService() {
try {
await this.ormService.initialize();
console.log(`*** ORM service has been initialized ***`)
} catch(err: any) {
const msg = err.message ? err.message : err
throw new Error(`Error: ${msg}`);
}
}
For reference the repository i used is:
ionic-sqlite-typeorm-app
Thank you in advance !