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'

2
  • You've spelled Database in openDatabase wrong. Maybe that was your problem. Commented Aug 23, 2016 at 11:17
  • No. This was a problem of documentation. I corrected it and still got errors. The real solution is desbribed bellow. Probably I was usin an outdated version of Ionic 2. Commented Aug 23, 2016 at 14:28

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

May be try to import SQLite object using

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

Note : Dont forget to install ionic-native/sqlite

npm install --save @ionic-native/sqlite

Comments

0

I resolved this issue by following steps.

Add and install plugin

ionic cordova plugin add cordova-sqlite-storage

npm install --save @ionic-native/sqlite

Now create a database.

let db = new SQLite();
            db.openDatabase({
                name: "data.db",
                location: "default"
            }).then(() => {
});

If you getting an error like: "openDatabse does not exist on type 'SQLite". Just delete node_module folder and reinstall node_module.

It will work.

Comments

-1

It's db.openDatabase, not Databse

But I think that now it's .create and not .openDatabase.

When you say .then(() => {db.executeSql ... try to add .then((db: SQLiteObject) and for the next then : {}).then(() => {}, (err) => { add data between the ( )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.