Daily Archives

One Article

How to add SQL Storage in your ionic2 App

So There might be cases when you would like to storage some data in local sql database , this can be useful for something like a todo App , Since there is no point in creating a remote database for a simple to do application.

In Ionic2 You implement SQL Storage as follows:

First I need to import two things

import {SqlStorage} from 'ionic-angular';
import {StorageEngine} from 'ionic-angular';

Here is one handy  & small tip  for you all (If you are using VS Code) , Sometimes we forget the exact name of the thing we are importing but we do remember for example it belongs to ionic-angular library , In such cases you can do this , Just write import{} from ‘ionic-angular’ (yeah dont write anything between the curly braces , now start typing inside the curly braces you will see the autocompletion ( 🙂 yay ! ) , I think the reason the intellisense or autocompletion list doesnt appear before you type ionic-angular is that Ionic doest know which library you are targeting but once you specify you are targeting ionic-angular , VS Code can show you a list of all the stuff that you can import from ionic-angular

blog_sql_1

You can watch the tutorial at :

https://www.youtube.com/watch?v=9rMGQT_Eqqo&feature=youtu.be