GithubHelp home page GithubHelp logo

ionic-storage's Introduction

Build Status

Ionic Storage

A simple key-value Storage module for Ionic apps. This utility uses the best storage engine available on the platform without having to interact with it directly (some configuration required, see docs below).

As of 3.x, this library now supports any JavaScript project (old versions only supported Angular), and Angular-specific functionality has been moved to a new @ionic/storage-angular package.

Out of the box, Ionic Storage will use IndexedDB and localstorage where available. To use SQLite for native storage, see the SQLite Installation instructions.

For teams building security sensitive applications requiring encryption, 3.x now supports encryption through Ionic Secure Storage, see Encryption Support for instructions on using it.

Installation

npm install @ionic/storage

If using Angular, install the @ionic/storage-angular library instead:

npm install @ionic/storage-angular

If you'd like to use SQLite as a storage engine, see the SQLite Installation instructions.

Usage

With React, Vue, Vanilla JavaScript

import { Storage } from '@ionic/storage';

const store = new Storage();
await store.create();

See the API section below for an overview of the supported methods on the storage instance.

With Angular

Usage in Angular using Services and Dependency Injection requires importing the IonicStorageModule and then injecting the Storage class.

First, edit your NgModule declaration in src/app/app.module.ts or in the module for the component you'll use the storage library in, and add IonicStorageModule as an import:

import { IonicStorageModule } from '@ionic/storage-angular';

@NgModule({
  imports: [
    IonicStorageModule.forRoot()
  ]
})
export class AppModule { }

Next, inject Storage into a component. Note: this approach is meant for usage in a single component (such as AppComponent). In this case, create() should only be called once. For use in multiple components, we recommend creating a service (see next example).

import { Component } from '@angular/core';
import { Storage } from '@ionic/storage-angular';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html'
})
export class AppComponent {

  constructor(private storage: Storage) {
  }

  async ngOnInit() {
    // If using a custom driver:
    // await this.storage.defineDriver(MyCustomDriver)
    await this.storage.create();
  }
}

For more sophisticated usage, an Angular Service should be created to manage all database operations in your app and constrain all configuration and database initialization to a single location. When doing this, don't forget to register this service in a providers array in your NgModule if not using providedIn: 'root', and ensure that the IonicStorageModule has been initialized in that NgModule as shown above. Here's an example of what this service might look like:

import { Injectable } from '@angular/core';

import { Storage } from '@ionic/storage-angular';

@Injectable({
  providedIn: 'root'
})
export class StorageService {
  private _storage: Storage | null = null;

  constructor(private storage: Storage) {
    this.init();
  }

  async init() {
    // If using, define drivers here: await this.storage.defineDriver(/*...*/);
    const storage = await this.storage.create();
    this._storage = storage;
  }

  // Create and expose methods that users of this service can
  // call, for example:
  public set(key: string, value: any) {
    this._storage?.set(key, value);
  }
}

Then, inject the StorageService into your pages and other components that need to interface with the Storage engine.

API

The Storage API provides ways to set, get, and remove a value associated with a key, along with clearing the database, accessing the stored keys and their quantity, and enumerating the values in the database.

To set an item, use set(key, value):

await storage.set('name', 'Mr. Ionitron');

To get the item back, use get(name):

const name = await storage.get('name');

To remove an item:

await storage.remove(key);

To clear all items:

await storage.clear();

To get all keys stored:

await storage.keys()

To get the quantity of key/value pairs stored:

await storage.length()

To enumerate the stored key/value pairs:

storage.forEach((key, value, index) => {
});

To enable encryption when using the Ionic Secure Storage driver:

storage.setEncryptionKey('mykey');

See Encryption Support below for more information.

Configuration

The Storage engine can be configured both with specific storage engine priorities, or custom configuration options to pass to localForage. See the localForage config docs for possible options: https://github.com/localForage/localForage#configuration

In React/Vue/Vanilla JavaScript configuration

Pass configuration options in the Storage constructor:

const storage = new Storage({
  name: '__mydb',
  driverOrder: [Drivers.IndexedDB, Drivers.LocalStorage]
});

Angular configuration

import { Drivers, Storage } from '@ionic/storage';
import { IonicStorageModule } from '@ionic/storage-angular';

@NgModule({
  //...
  imports: [
   IonicStorageModule.forRoot({
     name: '__mydb',
     driverOrder: [Drivers.IndexedDB, Drivers.LocalStorage]
   })
 ],
 //...
})
export class AppModule { }

SQLite Installation

The 2.x version of this plugin hard coded in the localForage-cordovaSQLiteDriver. This driver has been removed from the core code as of 3.x to provide more options for SQLite storage engines.

In 3.x there are at least two good options for SQLite usage:

  1. For non-enterprise apps, the old localForage-cordovaSQLiteDriver is still a fine choice but does not support encryption and is community maintained. See below for installation instructions.

  2. For enterprise apps, we strongly recommend Ionic Secure Storage which is an enterprise SQLite engine with full encryption support out of the box and is fully supported and maintained by the Ionic team.

Using localForage-CordovaSQLiteDriver

Installation

# If using Cordova, install the plugin using 
ionic cordova plugin add cordova-sqlite-storage
# If using Capacitor, install the plugin using
npm install cordova-sqlite-storage

# Then, install the npm library
npm install localforage-cordovasqlitedriver

Adding driver to configuration

For non-Angular projects, pass the CordovaSQLiteDriver._driver to the driverOrder config option:

import CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';

const store = new Storage({
  driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
});

In Angular, pass the same configuration when importing the IonicStorageModule in your page or app NgModule:

import CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';

@NgModule({
  imports: [
    // ...,
    IonicStorageModule.forRoot({
      driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB]
    })
  ],
  // ...
})
export class MyPageModule { }

Registering Driver

Finally, to register the driver, run defineDriver() on the storage instance to register the driver, making sure to call this before any data operations:

import CordovaSQLiteDriver from 'localforage-cordovasqlitedriver'

const store = new Storage({
  driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
});

await this.storage.defineDriver(CordovaSQLiteDriver);

Using Ionic Secure Storage

Ionic Secure Storage is an enterprise-ready, high-performance data store with SQL or key/value support and offering 256-bit AES encryption. When used in tandem with Ionic Identity Vault, developers can securely manage encryption keys and build fully offline-enabled apps with biometric authentication using the fullest security capabilities available on modern mobile devices and operating systems.

Ionic Secure Storage is an enterprise product and requires an active enterprise subscription or trial. To learn more and request a demo, visit the Secure Storage product page.

Installation

Follow the official installation guide to set up and install @ionic-enterprise/secure-storage.

Usage

With React, Vue, Vanilla JavaScript

import { Drivers } from '@ionic/storage';
import IonicSecureStorageDriver from '@ionic-enterprise/secure-storage/driver';

const store = new Storage({
  driverOrder: [Drivers.SecureStorage, Drivers.IndexedDB, Drivers.LocalStorage]
});

await store.defineDriver(IonicSecureStorageDriver);

With Angular

Usage in Angular using Services and Dependency Injection requires importing the IonicStorageModule and then injecting the Storage class.

First, edit your NgModule declaration in src/app/app.module.ts or in the module for the page you'll use the storage library in, and add IonicStorageModule as an import:

import { Drivers } from '@ionic/storage';
import { IonicStorageModule } from '@ionic/storage-angular';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    IonicStorageModule.forRoot({
      driverOrder: [Drivers.SecureStorage, Drivers.IndexedDB, Drivers.LocalStorage]
    })
  ],
  // ...
})
export class AppModule { }

Then register the driver in your component:

  async ngOnInit() {
    await this.storage.defineDriver(IonicSecureStorageDriver);
    await this.storage.create();
  }

Then follow the instructions below to configure encryption support:

Encryption Support

3.x adds a new method setEncryptionKey to support encryption when using with Ionic Secure Storage (see instructions above).

This is an enterprise feature for teams with high security needs and provides the ability to use the simple @ionic/storage key-value API, or drop down to SQL for more powerful query and relational data support, all with full encryption. When paired with Ionic Identity Vault teams can safely manage encryption keys and provide biometric authentication when on or offline.

Visit the Secure Storage product page to learn more about Secure Storage and inquire about a trial.

Encrypting an Existing SQLite Database

A one-time migration must be performed to move to a new, encrypted database powered by Ionic Secure Storage.

First, follow the installation steps above to update to Ionic Storage v3, install the localForage-CordovaSQLiteDriver SQLite driver, and integrate Ionic Secure Storage.

Next, remove the database name and drivers, if used, from app.module.ts:

@NgModule({
  imports: [
    // ...,
    IonicStorageModule.forRoot()
  ],
  // ...
})
export class MyPageModule { }

Finally, in the service class, create a one time migration function that migrates data to an encrypted database. Execute this function on app load.

async migrateDatabase() {
  const origStore = new Storage({
    name: 'originalDB', // the original database name
    driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
  });
  await origStore.defineDriver(CordovaSQLiteDriver);

  const newStore = new Storage({
    name: 'encryptedDB', // pick a new db name for the encrypted db
    driverOrder: [Drivers.SecureStorage, Drivers.IndexedDB, Drivers.LocalStorage]
  });
  await newStore.defineDriver(IonicSecureStorageDriver);
  newStore.setEncryptionKey('mykey');

  if (await origStore.length() > 0) {
    // copy existing data into new, encrypted format
    await origStore.forEach((key, value, index) => {
      newStore.set(key, value);
    });

    // remove old data
    await origStore.clear();
  }

  this._storage = newStore;
}

ionic-storage's People

Contributors

abennouna avatar adamdbradley avatar amayvs avatar brandyscarney avatar ceotrammell avatar danbucholtz avatar danielsogl avatar dotnetkow avatar ionitron avatar jgw96 avatar juliandavidmr avatar kensodemann avatar manduro avatar mhartington avatar mlynch avatar nonameprovided avatar perrygovier avatar rtpharry avatar sean-perkins avatar socuul avatar theaninova avatar thgreasi avatar tripodsgames avatar wbhob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-storage's Issues

ES5 builds might be bugged

Not sure if there is any consumer for the ES5 builds but due to a discussion at localforage I might be able to point out a bug in this build.

// es5/storage.js

...

var localforage_1 = require('localforage');

...

var Storage = (function () {
    function Storage() {
        var _this = this;
        this._db = localforage_1.default; // localforage_1 has no field named default.

...

Unless the require() or your bundler does some magic localforage_1 has no field named default

To verify this open a node REPL

var lf = require('localforage')
lf.default // should be undefined

wrong typings with v1.1.6

I updated my app to @ionic/storage to v1.1.6 and I can't use the setEngine method because it isn't present in the typings (absent in both es5/storage.d.ts and es2015/storage.d.ts). Tried installing, removing, reinstalling, etc.

Add cordova-plugin-nativestorage implementation of IStorageEngine

From @jgw96 on December 29, 2016 21:35

From @imgx64 on September 1, 2016 5:55

Short description of the problem:

The cordova-plugin-nativestorage plugin provides NativeStorage, a key/value store that stores data into Sharedpreferences on Android and NSUserDefaults in iOS. It would be nice to have an IStorageEngine wrapper for it as a third alternative to SqlStorage and LocalStorage.

Which Ionic Version? 1.x or 2.x
Ionic 2.

Copied from original issue: ionic-team/ionic-framework#7935

Copied from original issue: danielsogl/awesome-cordova-plugins#924

Feature/Proposal: use NativeStorage plugin

I think Ionic Storage could be simplified by not using LocalForage at all. Instead use LocalStorage on the browser, and NativeStorage on mobile.

I find LocalForage dangerous because it auto-selects the driver and it may not be obvious to the developer which one it uses. If somebody doesn't add the SQLite plugin the app will start storing data in IndexedDB. Then they may add the SQLite plugin in a later release of the app (to store different kind of data) and all of a sudden the existing data saved in IndexedDB won't be visible any more.

(Also, the localForage-cordovaSQLiteDriver opens a SQLite db but never seems to close it, which I'm not sure it's a good thing.)

The NativeStorage plugin uses SharedPreferences on Android and NSUserDefaults on iOS, i.e. what native app developers would use for storing simple key-value pairs.

I'll be putting together a project in its own repository when I have some time, but wanted to throw the idea here as well.

Performance issue ?

Im not sure why this code doesnt work, it works in a browser but on a live phone my OnInit returns nothing but if I click the button that calls the checkCookie() function it returns the cookie.. I need to display the users data after they open and close the app and I was hoping this could be achieved using ionic-storage.

  import { Component, OnInit, NgZone } from '@angular/core';
  import { NavController } from 'ionic-angular';
  
  import { UserData } from '../../providers/user-data';
  
  import { Storage } from '@ionic/storage';
  
  
  
  @Component({
    selector: 'page-home',
    templateUrl: 'home.html'
  })
  export class HomePage implements OnInit {
  
    constructor( public ngZone: NgZone, 
                 public navCtrl: NavController,
                 public api: UserData,
                 public storage: Storage ) {  }
  
  
      ngOnInit() {
  
        this.checkCookie();
  
      }
  
      checkCookie() {
          this.storage.get('FacebookData').then((FacebookData) => {
              alert('COOKIESET ' + JSON.stringify(FacebookData)   );
          });
      }
  
  }

Dealing with functions for storage.get

I have a function verify if a user exists:

userIsLogged() {
    this.storage.get('token').then((token) => {
      if (token) {
        return true;
      }
      else {
        return false;
      }
    }); 
  }

But, when I call this function, it should return a boolean, but It's returning a void. Because storage.get has a promise. How can I deal with this. I'm using this function userIsLogged() to show or hide an element in the view.

Build dev failed: no such file or directory \node_modules\@ionic\storage\dist\es5

I uninstalled and reinstalled @ionic/storage with --save on my project but ever since get this error message when running ionic serve:

[11:22:47]  Error: Could not resolve entry (./.tmp/app/main.dev.js)
    at C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\rollup\dist\rollup.js:8602:28
    at process._tickCallback (internal/process/next_tick.js:103:7)

[11:22:47]  sass started ...
[11:22:47]  build dev failed:  Build failed: ENOENT: no such file or directory, scandir 'c:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\storage\dist\es5'

[11:22:47]  Error: ENOENT: no such file or directory, scandir 'c:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\storage\dist\es5'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at getSiblingSassFiles (C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:126:17)
    at addComponentSassFiles (C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:100:24)
    at C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:95:9
    at Array.forEach (native)
    at getComponentSassFiles (C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:94:26)
    at generateSassData (C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:79:30)
    at Object.sass (C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\sass.js:38:9)
    at C:\Daten\Entwicklung\e-netz\PROMT-UI_V2\node_modules\@ionic\app-scripts\dist\build.js:63:23

Looking at the node_modules/@ionic/storage directory the error message is correct: There is no "dist" directory, only es5 and es2015.

My package.json:

{
  "dependencies": {
    "@ionic/storage": "^1.1.2",
    "ag-grid": "^6.0.1",
    "ag-grid-enterprise": "^6.0.1",
    "angular-2-local-storage": "0.0.19",
    "electron-squirrel-startup": "^1.0.0",
    "ionic-angular": "^2.0.0-rc.0",
    "ionic-native": "^2.0.3",
    "ionicons": "^3.0.0",
    "keycloak": "^1.2.0",
    "ng2-resource-rest": "^1.4.0",
    "reflect-metadata": "0.1.8"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^0.0.23",
    "tslint-ionic-rules": "0.0.5",
    "typescript": "^2.0.3"
  },
  "name": "promtui",
  "description": "Promt-UI: An Ionic 2 project",
  "version": "1.0.0",
  "author": "Juergen Wahlmann",
  "build": {
    "appId": "promt-ui",
    "category": "demo",
    "win": {
      "iconUrl": "http://resources/icon.ico",
      "msi": true
    },
    "asar": false
  },
  "directories": {
    "app": "dist/desktop/www"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "scripts": {
    "electron": "electron dist/desktop/build/windows/resources/app",
    "electron dist": "electron dist/desktop/build/windows/resources/app",
    "build1": "electron-packager dist/desktop/build/windows/resources/app PROMT-UI  --ignore=node_modules/* --platform=win32 --arch=all",
    "pack": "build --dir",
    "dist": "build",
    "build": "ionic-app-scripts build",
    "watch": "ionic-app-scripts watch",
    "serve:before": "watch",
    "emulate:before": "build",
    "deploy:before": "build",
    "build:before": "build",
    "run:before": "build"
  },
  "engines": {
    "node": ">= 6.6.0",
    "npm": ">= 3"
  },
  "config": {
    "ghooks": {
      "pre-commit": "npm run lint && npm run scss-lint",
      "pre-push": "npm test",
      "commit-msg": "validate-commit-msg"
    },
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

Also, if I uninstall @ionic/storage to solely use angular-2-local-storage it still references this missing directory. I could not find that reference anywhere in my project.

Any ideas how to solve this?

Using @ionic-storage with latest Ionic 2 Config

I recently used the CLI to generate an Ionic 2 app, but when I try and add Ionic storage it throws an error related to the import statement. It would appear that there is some sort of issue with the new tsconfig module setting and ionic-storage.

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Asset Version Info

"ionic-angular": "2.0.0-beta.11"
"@angular/core": "2.0.0-rc.4",
"@ionic/storage": "^1.1.6"

Environment

node v6.3.1

TS Config

"module": "commonjs"

bug(sqlite): Promise to indicate that the storage engine is properly initialized

This plugin works perfectly on the browser as it uses indexedDB. On a device with the sqlite plugin, the sqlite database initializes at it's own pace and the user may try and use the storage before it is properly setup.

In my case I read a whole bunch of values from the storage when the platform ready event fires. The problem is that the sqlite plugin is not yet initialized at this point and everything is returned as null.

I highly suggest implementing a promise or something that a client can use to ensure that no matter the engine being used is properly initialized before they begin to use storage.

Some logs to show me trying to read files from storage when platform ready fires, but the sqlite db is not yet initialized.

2016-11-21 21:57:16.577 Cochrane[14442:351235] DEVICE READY FIRED AFTER 531 ms
2016-11-21 21:57:16.583 Cochrane[14442:351235] App initializing......

2016-11-21 21:57:16.620 Cochrane[14442:351235] STORAGE WebServiceUrl : null
2016-11-21 21:57:16.624 Cochrane[14442:351235] STORAGE LastKnownLatitude : null
2016-11-21 21:57:16.628 Cochrane[14442:351235] STORAGE LastKnownLongitude : null
2016-11-21 21:57:16.633 Cochrane[14442:351235] STORAGE AppUserEmail : null
2016-11-21 21:57:16.638 Cochrane[14442:351235] STORAGE AuthToken : null
2016-11-21 21:57:16.643 Cochrane[14442:351235] STORAGE RequestQueue : null
2016-11-21 21:57:16.658 Cochrane[14442:351235] STORAGE DeviceIdentifier : null
2016-11-21 21:57:16.658 Cochrane[14442:351235] storage is initialized.
2016-11-21 21:57:16.660 Cochrane[14442:351235] OPEN database: _ionicstorage
2016-11-21 21:57:16.660 Cochrane[14442:351235] -[SQLitePlugin pluginInitialize] [Line 33] Initializing SQLitePlugin
2016-11-21 21:57:16.660 Cochrane[14442:351235] -[SQLitePlugin pluginInitialize] [Line 44] Detected docs path: /Users/dylan/Library/Developer/CoreSimulator/Devices/F0245ED7-EC96-4092-9278-9EF7558D50A9/data/Containers/Data/Application/97E131FA-16B4-4BF8-93C4-3A0C069DBF60/Documents
2016-11-21 21:57:16.660 Cochrane[14442:351235] -[SQLitePlugin pluginInitialize] [Line 48] Detected Library path: /Users/dylan/Library/Developer/CoreSimulator/Devices/F0245ED7-EC96-4092-9278-9EF7558D50A9/data/Containers/Data/Application/97E131FA-16B4-4BF8-93C4-3A0C069DBF60/Library
2016-11-21 21:57:16.661 Cochrane[14442:351235] -[SQLitePlugin pluginInitialize] [Line 55] no cloud sync at path: /Users/dylan/Library/Developer/CoreSimulator/Devices/F0245ED7-EC96-4092-9278-9EF7558D50A9/data/Containers/Data/Application/97E131FA-16B4-4BF8-93C4-3A0C069DBF60/Library/LocalDatabase
2016-11-21 21:57:16.661 Cochrane[14442:351235] new transaction is waiting for open operation
2016-11-21 21:57:16.661 Cochrane[14442:351342] -[SQLitePlugin openNow:] [Line 137] open full db path: /Users/dylan/Library/Developer/CoreSimulator/Devices/F0245ED7-EC96-4092-9278-9EF7558D50A9/data/Containers/Data/Application/97E131FA-16B4-4BF8-93C4-3A0C069DBF60/Library/LocalDatabase/_ionicstorage
2016-11-21 21:57:16.674 Cochrane[14442:351342] -[SQLitePlugin openNow:] [Line 163] Good news: SQLite is thread safe!
2016-11-21 21:57:16.677 Cochrane[14442:351235] initializing location...
2016-11-21 21:57:16.740 Cochrane[14442:351235] App Initialization complete...
2016-11-21 21:57:16.754 Cochrane[14442:351235] OPEN database: _ionicstorage - OK

Prepare for localforage v1.5 upgrade

We just merged localForage/localForage#611 which adds typescript typings as part of the repo and it's planned to be released (at some point) as v1.5.0.
The respective change on localforage-cordovasqlitedriver is going to be released as v1.6.0 and is currently under the lf1.5 branch.

Just giving you a note about that, in order to avoid any "duplicate identifier" errors when v1.5 gets released.
Most probably, all that needs to be done is to remove the @types/localforage package.
I will try to keep you posted.

Cannot install v1.1.7

When I run

npm install @ionic/storage

version 1.1.6 installed
I tried run

npm i driftyco/ionic-storage
ionic-hello-world@ /home/aaa/aaa
โ””โ”€โ”€ @ionic/[email protected]  invalid (git://github.com/driftyco/ionic-storage.git#ec6fca00eeead2fee2befdf2f66fddb0d9fee924)

My config:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.16
Node Version: v5.10.1
Xcode version: Not installed

Storage from @ionic/storage loses data

From @Lafaa on October 30, 2016 16:29

Hi guys!
Am i the only one having problem with the new Storage since the ionic2 rc0?

It just forgets everything once the app is restarted. I use the Storage class from @ionic/storage to save username and password, but it's like it get cleaned on app restart.

I'm using the Storage this way:

 public storage: Storage;
...
this.storage = new Storage();
...
this.storage.set(key, value);

I've also added the Storage in app.module.ts, both in the import section AND in the providers array.
Did i get something wrong? In the running and building process i don't have any error or warnings

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0-201610131811
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v6.7.0

Copied from original issue: ionic-team/ionic-framework#8959

Delete value

How do I delete a certain key => value pair with this? key => null???

Storage never actually uses SQLite

The README says

Currently the ordering is SQLite, IndexedDB, WebSQL, and LocalStorage.

One reason we prioritize SQLite is because of some OS-dependent issues with storage in the browser in native apps. As a major example, iOS will currently clear out Local Storage (and IndexedDB it's been shown) when the device runs low on memory. To avoid that, a file-based storage approach with SQLite will retain all your data.

However when running my app on iOS I noticed it was using IndexedDB, even though I did install the cordova-sqlite-storage plugin.

So I patched storage.js to log which driver it was using

    this._db.setDriver([
        CordovaSQLiteDriver._driver,
        this._db.INDEXEDDB,
        this._db.WEBSQL,
        this._db.LOCALSTORAGE
    ]).then(function () {
        console.log('Storage driver:', this._db.driver());
    }.bind(this));

and it is indeed logging Storage driver: โ€“ "asyncStorage", where asyncStorage is the value for INDEXEDDB as defined in localforage.js.

Adding some more logging shows that cordovaSQLiteDriver is not recognised as a supported driver, even though window.sqlitePlugin is defined.

WS error message

On RC4 / Storage 1.1.7 , if you try

ionic serve --consolelogs

you see an error that is not actually seen in the browser console log

[19:52:58]  error opening ws message: {"category":"console","type":"info","data":["Ionic Storage 
            driver:","asyncStorage"]} 

Not sure what that is, but looks storage related. Seems to work though, even with this error message.

Add logging to indicate the storage engine in use

At the moment there is no indication as to the storage engine that is in use. It would be good to have at least a console log statement that say something like "ionic.storage engine in use is SQLITE".

The previous storage/sqlstorage implementation used to do something along these lines.

How to save a lot of data?

Q: I need to ceche a lot of books,every book got 3 or more cols like book's cover image,book's title,book's publish id.**could some tell me how to?and any way to read them all?

Race conditions

You should point out in your documentation that the ready function exists starting v 1.1.7 and should be used before any DB access is made. I have not yet been able to test it, but I ran into this problem with v1.1.6 that installed as the default version in my ionic2 project.

With 1.1.7 works much better... Problem solved

Double initialisation?

On 1.1.7 (and earlier), in the browser console logs, I aways see 2 of

Ionic Storage driver: asyncStorage

This is not broken as such, in that it all works, but perhaps the code is initialising twice? In the context of finding performance gains, I wonder if this something that could be looked at?

Incidentally, this error message (separate issue), was also seen twice
#53

IonicStorage 1.1.6 - Opening database is delayed

Hello,
With reference to Ionic Storage - QuotaExceededError - error - #10
I have now used @ionic/Storage 1.1.6 withcordova-sqlite-storage - 1.4.8
In my platform.ready() code

I have used

storage.get('introShown').then((res) =>{
});

it gives me res = null;

The reason is database is opening delayed after my call to get.

getting data for.... env
main.js:29 DEVICE READY FIRED AFTER 697 ms
main.js:30 getting data for.... introShown
main.js:29 Ionic Storage driver: cordovaSQLiteDriver
main.js:30 setting data for.... introShown  value... true
SQLitePlugin.js:175 OPEN database: _ionicstorage
SQLitePlugin.js:106 new transaction is waiting for open operation
SQLitePlugin.js:179 OPEN database: _ionicstorage - OK
SQLitePlugin.js:80 DB opened: _ionicstorage

Property 'query' does not exist on type 'Storage'.

From @mvsiva4u on November 15, 2016 12:25

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/

Short deiscription of the problem:

if i used below sqllite to get data from sql list database
this.storage.query(sql, [data.institutionid, data.app, data.capability]);

What behavior are you expecting?

Steps to reproduce:
1.
2.
3.

insert any relevant code between the above and below backticks (```)

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Run ionic info from terminal/cmd prompt: (paste output below)

Copied from original issue: ionic-team/ionic-conference-app#314

Cannot read property 'name' of null

I've stored some images as Base64 strings in storage using the image URL as the key. This is effectively an image cache to save some user data while using my app. When using Ionic Serve I sometimes run into the error in the issue title. This does not happen on a device though. It also does not happen with every item.

The source function that causes this error is:

var promise = self._initReady().then(function () {
        var dbContext = dbContexts[self._dbInfo.name];

        if (dbContext && dbContext.dbReady) {
            return dbContext.dbReady;
        }
});

That self._dbInfo is null and the accessing the name property causes an exception.

I've handled the promise rejection in my code so the app isn't crashing but now those storage items are inaccessible.

feat: ability to specify preferred storage type

It would be create to have an enum passed into the Storage constructor that allows the user to specify their preferred storage type.

If their preferred storage type is not available, show a warning in the console, and then proceed to pick the next best storage option as you normally would.

The reason why I want this is because when I am working in the browser, I would very much like to use localstorage over everything else. Especially when running ionic serve and debugging on chrome and changing the device types quite a lot, the IndexedDb instance resets which is a pain. Localstorage persists quite nicely in this case.

Data not cleared on Android

I have logout function which I try to clear all storage data and they are not cleared.

logout() {
        this.storage.clear().then((data) => {
			console.log(data);
		})
    	this.storage.remove('token');
   	this.storage.remove('profile');
   	this.storage.remove('login');
};   

In fact when I debug with chrome://inspect#device I don't see any data but they are loaded.

Ionic Storage driver: cordovaSQLiteDriver   SQLitePlugin.js:175 
OPEN database: _ionicstorage      SQLitePlugin.js:106 
new transaction is waiting for open operation     SQLitePlugin.js:179 
OPEN database: _ionicstorage - OK   SQLitePlugin.js:80 
DB opened: _ionicstorage         SQLitePlugin.js:80 

I don't see any data. In chrome web it works but not on android.
screen shot 2016-12-05 at 22 12 34

LocalStorage

hi, i'm updating my project from las ionic beta to the recent rc0 and storage moved here, but LocalStorage is gone, is this on purpose ? should we use sql only now ?

Angular 2 only?

I can't find this clearly documented anywhere in the project - this module is for Angular 2 only, and doesn't support Angular 1.x, correct?

get throwing exception

I am using @ionic/[email protected]

Often when this code runs I get an exception. Should this throw anything ever?

let local = new Storage();
local.get('isSetup') <----

I didn't see this on earlier version.

How to use best. Cannot assign to Class variable.

Is this normal to call like this or what's the best usage because nothing else is working

    this.storage.get('email').then((email) => {
	    this.storage.get('token').then((token) => {
	  
	      this.http.get('https://app.dev/clients.json?login='+email+'&client_token='+token)
	          .map(res => res.json())
	          .subscribe(data => {
	            // we've got back the raw data, now generate the core schedule data
	            // and save the data for later reference
	            this.data = data;
	            resolve(this.data);
	          });
	      });
	    });
    });

I tried

  data: any;
  token: string;
  phone:string;
  constructor( private http: Http, public storage: Storage) {}


 load() {

    this.storage.get('token').then((token) => {
    this.token = token;

    });
    this.storage.get('phone').then((phone) => {
    this.phone = phone;
    });   

      this.http.get('https://app.dev/clients.json?login='+this.phone+'&client_token='+this.token)
	          .map(res => res.json())
	          .subscribe(data => {
	            // we've got back the raw data, now generate the core schedule data
	            // and save the data for later reference
	            this.data = data;
	            resolve(this.data);
	          });
	      });

But this.phone = phone; is not assigned

I wish I could just call this.storage.get('phone') and no promises.

ES5 should be the default "main" in package.json

package.json has the following:

  "main": "es2015/index.js",
  "module": "es2015/index.js",

I think this should be "main": "es5/index.js". Currently es2015 module is used by default if you import @ionic/storage, which breaks non-module-aware tools like browserify. I use browserify for karma tests, and this is breaking it. Even babelify doesn't work because @ionic/storage/es2015/index.js is in node_modules/ and babelify won't touch it unless I set global: true,, which produces a lot of unrelated errors.

This is the error I get when I run karma with browserify:

> karma start  --no-auto-watch --single-run

24 10 2016 09:46:50.363:ERROR [framework.browserify]: bundle error
24 10 2016 09:46:50.366:ERROR [framework.browserify]:
redacted/ionic-app/node_modules/@ionic/storage/es2015/index.js:1
import { Storage } from './storage';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

karma.conf.js:

module.exports = function(config) {
  config.set({
    basePath: '',

    files: [
      'node_modules/ionic-angular/polyfills/polyfills.js',
      'node_modules/jasmine-promises/dist/jasmine-promises.js',
      'src/**/*.spec.ts'
    ],

    exclude: [],

    frameworks: ['jasmine', 'browserify'],

    preprocessors: {
      '**/*.ts': ['browserify']
    },

    reporters: ['progress'],

    logLevel: config.LOG_INFO,

    browsers: ['PhantomJS'],

    browserify: {
      debug: true,
      extensions: ['.ts'],
      configure: function(bundle) {
        bundle.once('prebundle', function() {
          bundle
            .plugin('tsify')
            .transform('babelify', {
              // global: true,
              // ignore: /\/node_modules\/(?!@ionic\/storage)/,
              extensions: ['.js', '.ts'],
              presets: ['es2015']
            })
        });
      }
    }
  });
};

I tried to import @ionic/storage/es5 instead of @ionic/storage, but I hit issue #18 and couldn't proceed.

Storage's get function returns null

Now using the latest version [email protected], and using ionic version is ionic2 rc1.
Only debugging on the device have below problem(command:ionic run android -l -c -s --device), when debugging on the computer browser is normal(command: ionic serve).
After import Storage, and set key-value pairs like below:
storage.set('customer_id',1021);
after the above code, add the following code:
storage.get('customer_id').then((data)=>{
console.log('customer_id:'+data);
});

the issue is print customer_id's value is null. but when I click on a link to another page, then can get customer_id from storage, or when I restart, also can get correct value. only first time get value is null.

Bundle dev failed: localforage.js does not export default.

During bundle dev started ... I am getting:

Module .../node_modules/localforage/dist/localforage.js does not export default (imported by .../node_modules/@ionic/storage/es2015/storage.js)
    at Module.trace (.../node_modules/rollup/dist/rollup.js:7706:29)
    at ModuleScope.findDeclaration (.../node_modules/rollup/dist/rollup.js:7329:22)```

Error reading template file, "my-component-tpl.html"

When I run ionic serve I get the following error:

Error reading template file, "my-component-tpl.html": Error: ENOENT: no such file or directory, open '/Users/jackvial/Code/cordova/driverAppIonic/node_modules/@ionic/storage/node_modules/@angular/core/src/animation/my-component-tpl.html'

Ionic Storage - QuotaExceededError - error -

From @bimal72 on October 3, 2016 10:10

Hello,
I was using SqlStorage in beta 11. My requirement is simple, storing key-value pair.
I have just changed to @ionic/storage.
As per its documents, it says that
A simple key-value Storage module for Ionic apps based on LocalForage, with out-of-the-box support for SQLite. This utility makes it easy to use the best storage engine available without having to interact with it directly. Currently the ordering is SQLite, IndexedDB, WebSQL, and LocalStorage.

Hence I have deployed it in one of my device for testing and I found that it is throwing
EXCEPTION: Uncaught (in promise): QuotaExceededError: An attempt was made to add something to storage that exceeded the quota.

I am assuming it is using LocalStorage somehow. In beta 11 it was working very well using

new Storage(SqlStorage, { name: 'my_app' });

Copied from original issue: ionic-team/ionic-framework#8426

Can't install

I get a weird error trying to install it. This happened when I tried to create a sidemanu app in the new ionic. Below I tried specifically installing it but got this:

>npm install @ionic/storage
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:213:12)
npm WARN addRemoteGit     at emitTwo (events.js:100:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:185:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:821:16)
npm WARN addRemoteGit     at Socket.<anonymous> (internal/child_process.js:319:11)
npm WARN addRemoteGit     at emitOne (events.js:90:13)
npm WARN addRemoteGit     at Socket.emit (events.js:182:7)
npm WARN addRemoteGit     at Pipe._onclose (net.js:469:12)
npm WARN addRemoteGit  driftyco/localforage-cordovasqlitedriver#9803562a61c2172a69f3475f97e98922c0b49ac0 resetting remote C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-adc44a49771a5261e0152969fa2f1be9 because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-adc44a49771a5261e0152969fa2f1be9: Cloning into bare repository 'C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-adc44a49771a5261e0152969fa2f1be9'...
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-adc44a49771a5261e0152969fa2f1be9:
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-adc44a49771a5261e0152969fa2f1be9: fatal: unable to overwrite old ref-pack file: Is a directory
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:213:12)
npm WARN addRemoteGit     at emitTwo (events.js:100:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:185:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:821:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
npm WARN addRemoteGit  driftyco/localforage-cordovasqlitedriver#9803562a61c2172a69f3475f97e98922c0b49ac0 resetting remote C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-dcf0e8319b4cf3f9b06a408e9fc38b35 because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror https://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-dcf0e8319b4cf3f9b06a408e9fc38b35: Cloning into bare repository 'C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-dcf0e8319b4cf3f9b06a408e9fc38b35'...
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror https://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-dcf0e8319b4cf3f9b06a408e9fc38b35:
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror https://github.com/driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-dcf0e8319b4cf3f9b06a408e9fc38b35: fatal: Fetch attempted without a local repo
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:213:12)
npm WARN addRemoteGit     at emitTwo (events.js:100:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:185:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:821:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
npm WARN addRemoteGit  driftyco/localforage-cordovasqlitedriver#9803562a61c2172a69f3475f97e98922c0b49ac0 resetting remote C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692 because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror [email protected]:driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692: Cloning into bare repository 'C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692'...
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror [email protected]:driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692:
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror [email protected]:driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692: Permission denied (publickey).
npm ERR! git clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror [email protected]:driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692: fatal: The remote end hung up unexpectedly
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@ionic/storage"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12
npm ERR! code 128

npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror [email protected]:driftyco/localforage-cordovasqlitedriver.git C:\Users\Eu\AppData\Roaming\npm-cache\_git-remotes\git-github-com-driftyco-localforage-cordovasqlitedriver-git-9803562a61c2172a69f3475f97e98922c0b49ac0-4579512e1b145fa41359e3b52a372692
npm ERR! Permission denied (publickey).
npm ERR! fatal: The remote end hung up unexpectedly
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Business\upwork\RyanSchefke\mobilitEASE\npm-debug.log

Cannot load localforage-cordovasqlitedriver behind a firewall

The dependency localforage-cordovasqlitedriver cannot be loaded within enterprise setting due to closed ports and firewalls. A git clone can typically not access github directly.

Please use a npm dependency instead, as this is resolved via local enterprise caching repositories.

Storage constructor makes async initialization

Version 1.1.6 introduces async defining a driver inside Storage constructor.
It breaks using Storage in sync context (e.g. tests) and there is no way to reuse an initialization promise to delay a work with an instance of Storage.

db configuration change - how to migrate data

Hi @mlynch

I see you are using _ionickv table name at Line40 which earlier(in beta 11, ionic-angular) was kv. How can I migrate my data from kv to _ionickv if I start using rc0? Also, if in future this db configuration changes, it will again loss data in old table.

  this._db.config({
      name        : '_ionicstorage',
      storeName   : '_ionickv'
    });

Missing key returns null

If I try to get a key that doesn't exist, null is returned. In older versions of the Storage Ionic plugin, undefined was returned, which I think is more appropriate. Is this by design?

No provider for Storage!

Hey,

Great work with Ionic 2 guys. I've imported and injected the ionic-storage export ({ Storage } from '@ionic/storage') as a provider in NgModule. I've then imported it and DI it into a service. The problem is, as well as injecting this service into any component which uses it, we are also having to import Storage as well.

Does anyone know why this would be the case?

Thanks

Throw error when item not stored (Suggestion).

Instead of returning null for an item that doesn't exist, wouldn't it be better to return an error?

this.storage.get('item').then(data => {
    this.something = data;
}, err => {
    alert('Nothing here');
});

NativeStorage does this which makes writing out code easier instead of having if(!data) in all of my storage calls.

Windows phone error for SQL Lite

When I deploy to Windows 10 mobile device I get this error on Auth0 Lock login screen:
I believe this is so, because Auth0 Auth service depends upon ionic/storage.

Exception was thrown at line 3, column 8540 in ms-appx-web://aaa.td/www/build/polyfills.js
0x800a139e - JavaScript runtime error: Uncaught (in promise): Error: SQLite plugin is not present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.