首页 > 解决方案 > Unbale 在 Ionic 4 中使用 SQLite 创建表

问题描述

以下是我的组件代码

import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; 

constructor(private sqlite: SQLite){
    this.createTransactions();
}

createTransactions(){
   this.sqlite.create({
     name: 'sample.db',
     location: 'default'
   }).then((db: SQLiteObject) => {
         db.executeSql('CREATE TABLE IF NOT EXISTS transactions(transaction_id TEXT PRIMARY KEY, user_id TEXT, order_date DATE, order_number INTEGER, invoice_date DATE, processed_date DATE, transaction_amount FLOAT)')
         .then(res => alert('Executed SQL'))
         .catch(e => alert('cannot create table'+JSON.stringify(e))); //alerting this
   }).catch(e => alert('lite'+JSON.stringify(e)));
}

有人可以告诉我哪里做错了吗?

标签: sqlitetypescriptionic-frameworkionic4

解决方案


推荐阅读