离子3:如何使用存储(Sqlite)插件

离子3:如何使用存储(Sqlite)插件,sqlite,angular,ionic2,storage,ionic3,Sqlite,Angular,Ionic2,Storage,Ionic3,我已经创建了登录屏幕和主屏幕。我有一个对象,其中有三个数据必须使用sqlite存储。我不知道如何做到这一点 { "userId": "", "loginId": "", "passwd": "" } 我已经在sqlite存储代码所在的位置创建了一个提供程序 export class SqlStorage { constructor(public http: Http,private sqlite: SQLite) { console.l

我已经创建了登录屏幕和主屏幕。我有一个对象,其中有三个数据必须使用sqlite存储。我不知道如何做到这一点

{
      "userId": "",
      "loginId": "",
      "passwd": ""
    }
我已经在sqlite存储代码所在的位置创建了一个提供程序

export class SqlStorage {

  constructor(public http: Http,private sqlite: SQLite) {
    console.log('Hello SqlStorage Provider');

    this.sqlite.create({
      name: 'data.db',
      location: 'default'
    })
    .then((db: SQLiteObject) => {
      db.executeSql('create table kmartIndia(name VARCHAR(32))', {})
      .then((db) => { 
        console.log('Executed SQL');
      })
      .catch((e) => {
        console.log(e)
      });
    })
    .catch((e) => {
      console.log(e)
    });
  }

  setValue(){}

  getValue(){}

  removeValue(){}
}
我不知道该怎么做

如何创建一个表,如何设置,获取和删除我不太熟悉的值,这有什么帮助


经过一些挖掘,我发现了如何使这项工作

“create”方法似乎用于创建和打开数据库

在yout setValue()中,执行以下操作:

要从表中获取数据,请执行以下操作:

this.sqlite.create(
  {name: 'data.db', location: 'default'}
  ).then(
    (db: SQLiteObject) => {
      db.executeSql('select * from kmartIndia', {}).then( 
        (data) => {
          for(var i =0; i< data.rows.length;i++){
            yourVariable += data.rows.item(i).name
          }
        } 
      )
    }
  );
this.sqlite.create(
{name:'data.db',位置:'default'}
).那么(
(db:SQLiteObject)=>{
executeSql('select*fromKmartindia',{})。然后(
(数据)=>{
对于(var i=0;i

(我用+=,分配了值,但它只是一个例子:)

@mayur我看到了一个我无法理解它在哪里创建的,以及如何将对象设置到表中的对象在这里,请检查这个,谢谢@mosca90我不理解您的第6点这是您如何从.ts页面调用sql提供程序的@莫汉戈皮
this.sqlite.create(
  {name: 'data.db', location: 'default'}
  ).then(
    (db: SQLiteObject) => {
      db.executeSql('select * from kmartIndia', {}).then( 
        (data) => {
          for(var i =0; i< data.rows.length;i++){
            yourVariable += data.rows.item(i).name
          }
        } 
      )
    }
  );