Я использую плагин ionic Sqlite.При попытке создать таблицу я получаю эту ошибку в консоли:
«Console MessagesError: {« row »: {« length »: 0},« columnsActed »: 0}»
что я не понимаю, потому что я думаю, что мой код в порядке.
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { SQLite, SQLiteObject } from "@ionic-native/sqlite";
@Injectable()
export class DatabaseProvider {
theConsole: string = "Console Messages";
options: any = {
name: 'db_name.db',
location: 'default'
}
private db: SQLiteObject;
private isOpen: boolean;
constructor(public http: HttpClient,private sqlite: SQLite) {
console.log('Hello DatabaseProvider Provider');
this.connectToDb();
}
private connectToDb():void {
this.sqlite = new SQLite();
this.sqlite.create(this.options)
.then((db: SQLiteObject) => {
this.db = db;
this.isOpen = true;
console.log('Hello DatabaseProvider connected to db');
this.createTables();
})
.catch(e => {
this.theConsole += JSON.stringify(e);
console.log(this.getConsoleMessages());
});
}
private createTables():void{
this.createTableContatti();
}
private createTableContatti(): void{
var sql = 'create table IF NOT EXISTS contatti(id_contatto INTEGER PRIMARY
KEY AUTOINCREMENT,nome TEXT, data_nascita TEXT)';
this.db.executeSql(sql)
.then(() => {
this.theConsole += 'Executed SQL' + sql
console.log(this.getConsoleMessages());
})
.catch(e => {
this.theConsole += "Error: " + JSON.stringify(e)
console.log(this.getConsoleMessages());
});
}
Может кто-нибудь помочь, пожалуйста?Заранее спасибо