Below are my imports in my database.service.ts.
import { Platform } from '@ionic/angular';
import { Injectable } from '@angular/core';
import { SQLitePorter } from '@ionic-native/sqlite-porter/ngx';
import { HttpClient } from '@angular/common/http';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
import { BehaviorSubject, Observable } from 'rxjs';
Below is the constructor I am using to try to build the database.
constructor(private plt: Platform, private sqlitePorter: SQLitePorter, private sqlite: SQLite, private http: HttpClient) {
this.plt.ready().then(() => {
const conn = this.sqlite.create({
name: 'emotions.db',
location: 'default'
});
if (conn == null) throw Error('Failed to create database connection');
conn.then(() => {
console.log('Done');
})
});
}
This is run when the app begins, and throws the statement I told it to because the conn == null in this case.
I am unsure why this is occurring, as there are no build errors when doing 'ionic serve'.