在ionicframework中,针对sqlite的table_info出现意外的令牌?

3

我在ionic框架中使用PRAGMA table_info获取特定表的信息,但是当我尝试编译它时,出现了table_info的意外标记错误。但是当我在DB browser(SQLite)中尝试相同的查询时,我得到了结果。

我在我的应用程序中使用了CordovaSQLite插件。

PRAGMA table_info(contacts)

显然,Ionic不允许PRAGMA。 - CL.
@CL. 那我怎么才能知道 Ionic 中表格的信息,以及为什么 PRAGMA 在 Ionic 中不被允许? - Nidhin Kumar
@Nidhinkumar,你能展示一些代码吗?展示一下你是如何调用这个的。 - Krsna Kishore
1个回答

0
尝试像这样在查询中提供它
$cordovaSQLite.execute(self.db, 'PRAGMA table_info(category)').then(function (res) {
    for (var i = 0; i < res.rows.length; i++) {
      if (res.rows.item(i).name === 'is_deleted') {
        hasISDeleted = true;
      }
    }
    if (hasISDeleted === true) {
      $log.log('going to update category');
      var query = 'UPDATE category SET is_deleted = ? WHERE is_deleted IS NULL';
      prom = $cordovaSQLite.execute(self.db, query, ['false']).then(function (res) {
        console.log(res);
        $log.log('category response', res);
      });
      $log.log('category prom', prom);
      proms.push(prom);
      $q.all(proms).then(function () {
        defer.resolve('Sucess');
      });
    } else {
      defer.resolve('Sucess');
    }
  });

希望它能够正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接