SQLite and SQLiteObject not find, even after Import from '@ionic-native/sqlite'


#1

Hi All,
I am using Visual Studio Community-2017 version to do hands on CRUD operation in ionic2 and SQLite db.
I have added SQLite storage native addins into VS and now writing .ts for a dbprovider class.
I have imported SQLite and SQLiteObject but compiler can not find them. The code is like below:

dbprovider.ts

import { Injectable } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { SQLite, SQLiteObject } from ‘@ionic-native/sqlite’;

export class demo {
sqllite: SQLite;

sqliteobject: SQLiteObject;

}

these two declaration giving complier error, like “Cannot find name…”

Any clue ??


#2

Did you do all the other stuff for Ionic Native and this plugin?

https://ionicframework.com/docs/native/#Installation
https://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module


#3

Additionally, you need to inject these things in your controller and put access control qualifiers on them in order for DI to work properly.


#4

can you please little elaborate your comment, sorry I am novish in angular.


#5

yes these two step done, but no luck


#6

Read the docs carefully. Also think whether you can use ionic storage instead. It is much easier to work with. If you are directly dealing with SQLite, you throw away the convenience of being able to test in a browser environment.


#7

Thanks, after reinstalling the plugins now no compile error as per your provided doc.
However now createdb method not working, there is no error and i can not see any db created.
may be i am not looking at right place.

  1. i am using browser to test.
  2. i am finding the db to create at www folder.
  3. If i need to open an exiting db then , i should use openDBs() of SQLiteObject…right ?

Regarding Storage -> I believe this is only for JSON and key value pair data…correct ?


#8

browser is not one of the supported platforms for the sqlite plugin: https://github.com/litehelpers/Cordova-sqlite-storage/tree/storage-master/src[quote=“sumanghosh, post:7, topic:94104”]
Regarding Storage -> I believe this is only for JSON and key value pair data…correct ?
[/quote]

Correct - and it also works in the non-native platforms like browser.