Search code examples
sqlitetypescriptangularcordova-pluginsionic2

SQLite not working on Ionic 2


Cannot use SQLite plugin in my Angular 2/Ionic 2 project.

The way SQLite is instantiated accordint to the Ionic 2 documentation is not working.

Sublime give me an error message:

Supplied parameters do not match nay signature of the call target.

It means that the constructor shoud receive parameters. But what parameters?

Ionic 2 SQLite plugin documentation: http://ionicframework.com/docs/v2/native/sqlite/

import { SQLite } from 'ionic-native';

let db = new SQLite();
db.openDatabse({
  name: 'data.db',
  location: 'default' // the location field is required
}).then(() => {
  db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {

  }, (err) => {
    console.error('Unable to execute sql', err);
  })
}, (err) => {
  console.error('Unable to open database', err);
});

It also says Property 'openDatabse' does not exist on type 'SQLite'


Solution

  • Solved by recreating the project from scratch and coping old app folder, configs and reinstalling npm modules and ionic native plugins.