Я следую учебному пособию по IONIC 4 CRUD. Когда я попадаю в оператор SQL, я получаю сообщение об ошибке:
> Argument of type '{}' is not assignable to parameter of type 'any[]'.
> Type '{}' is missing the following properties from type 'any[]':
> length, pop, push, concat, and 26 more.ts
Это утверждение, где я получаю ошибку:
db.executeSql('CREATE TABLE IF NOT EXISTS expense(rowid INTEGER PRIMARY KEY, date TEXT, type TEXT, description TEXT, amount INT)', {})
db.executeSql('SELECT SUM(amount) AS totalIncome FROM expense WHERE type="Income"', {})
db.executeSql('SELECT SUM(amount) AS totalExpense FROM expense WHERE type="Expense"', {})
Я получаю красную линию на "{}"
Это весь код:
getData() {
this.sqlite.create({
name: 'ionicdb.db',
location: 'default'
}).then((db: SQLiteObject) => {
db.executeSql('CREATE TABLE IF NOT EXISTS expense(rowid INTEGER PRIMARY KEY, date TEXT, type TEXT, description TEXT, amount INT)', {})
.then(res => console.log('Executed SQL'))
.catch(e => console.log(e));
db.executeSql('SELECT * FROM expense ORDER BY rowid DESC', {})
.then(res => {
this.expenses = [];
for(var i=0; i<res.rows.length; i++) {
this.expenses.push({rowid:res.rows.item(i)
.rowid,date:res.rows.item(i).date,type:res.rows.item(i)
.type,description:res.rows.item(i).description,amount:res.rows.item(i).amount});
}
})
.catch(e => console.log(e));
db.executeSql('SELECT SUM(amount) AS totalIncome FROM expense WHERE type="Income"', {})
.then(res => {
if(res.rows.length>0) {
// tslint:disable-next-line: radix
this.totalIncome = parseInt(res.rows.item(0).totalIncome);
this.balance = this.totalIncome - this.totalExpense;
}
})
.catch(e => console.log(e));
db.executeSql('SELECT SUM(amount) AS totalExpense FROM expense WHERE type="Expense"', {})
.then(res => {
if(res.rows.length>0) {
// tslint:disable-next-line: radix
this.totalExpense = parseInt(res.rows.item(0).totalExpense);
this.balance = this.totalIncome - this.totalExpense;
}
});
}).catch(e => console.log(e));
}
Мне нужна твоя помощь. Спасибо.