question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic 3: Update SQLite documentation

See original GitHub issue

Bug Report

Ionic Info

✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.2 (/usr/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.4, (and 5 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/another/Android/Sdk)
   NodeJS            : v10.10.0 (/usr/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.15

Describe the Bug Following the SQLite plugin usage instructions found at https://ionicframework.com/docs/native/sqlite/ drives to an error.

Steps to Reproduce Started a new project with ionic start sqlitetest blank. Followed the instructions found in the documentation mentioned before and added this code to the default home.ts:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController, private sqlite: SQLite) {}

  ionViewDidLoad() {
    console.log('EXECUTING ionViewDidLoad');

    this.sqlite
      .create({
        name: 'data.db',
        location: 'default'
      })
      .then((db: SQLiteObject) => {
        db.executeSql('create table danceMoves(name VARCHAR(32))', {})
          .then(() => console.log('Executed creation SQL'))
          .catch(e => console.log('Error executing creation SQL: ' + JSON.stringify(e)));
      })
      .catch(e => console.log('Error opening DB: ' + JSON.stringify(e)));
  }
}

Executed ionic cordova emulate android -lc and got a typescript error:

captura de pantalla de 2018-09-13 19-18-32

Related Code I tried removing that offending parameter {} since it’s optional. I executed it again and got these log messages:

[app-scripts] [19:22:04]  build finished in 4.94 s
[app-scripts] [19:22:06]  console.log: Angular is running in the development mode. Call enableProdMode() to enable the production
[app-scripts]             mode.
[app-scripts] [19:22:06]  console.log: EXECUTING ionViewDidLoad
[app-scripts] [19:22:06]  console.log: OPEN database: data.db
[app-scripts] [19:22:06]  console.log: OPEN database: data.db - OK
[app-scripts] [19:22:06]  console.log: Ionic Native: deviceready event fired after 1119 ms
[app-scripts] [19:22:06]  console.log: Error executing creation SQL: {"rows":{"length":0},"rowsAffected":0}

Finally, I tried to change that parameter to [], uninstalled the app, redeployed it, and it worked:

[cordova]  INSTALL SUCCESS
[cordova]  LAUNCH SUCCESS
[app-scripts] [19:24:39]  console.log: Angular is running in the development mode. Call enableProdMode() to enable the production
[app-scripts]             mode.
[app-scripts] [19:24:39]  console.log: EXECUTING ionViewDidLoad
[app-scripts] [19:24:39]  console.log: OPEN database: data.db
[app-scripts] [19:24:39]  console.log: OPEN database: data.db - OK
[app-scripts] [19:24:39]  console.log: Ionic Native: deviceready event fired after 1072 ms
[app-scripts] [19:24:39]  console.log: Executed creation SQL

Expected Behavior The documentation is obsolete and I think SQLite is a pretty important plugin so it should be updated.

Additional Context I’m opening this issue because I started a project before and I couldn’t make SQLite work, so finally I had to change my app to use ionic-storage instead, despite its way of working isn’t optimal for the application I’m currently developing. Please, update the documentation so no other programmer has the same problem I had.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
brianmak3commented, Oct 29, 2018

try changing the {} to [] {} is not a known datatype

0reactions
ionitron-bot[bot]commented, Nov 28, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 3: Update SQLite documentation · Issue #15584 - GitHub
The documentation is obsolete and I think SQLite is a pretty important plugin so it should be updated. Additional Context I'm opening this...
Read more >
SQLite - Ionic Native
Open or create a SQLite database file. See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a- ...
Read more >
Ionic 3, Angular 4 and SQLite CRUD Offline Mobile App
Step by step tutorial on how to create an offline mobile app with Ionic 3, Angular 4 and SQLite using Native SQLite Plugin....
Read more >
SQlite UPDATE operation not working ionic 3 - Stack Overflow
I am using ionic 3 in my project with SQLite database. i have had all the other CRUD operations working except for the...
Read more >
@ionic-native/sqlite - npm
Ionic Native - Native plugins for ionic apps. Latest version: 5.36.0, last published: a year ago. Start using @ionic-native/sqlite in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found