@ionic/storage
Advanced tools
Comparing version 2.3.1 to 3.0.0-alpha.2
{ | ||
"name": "@ionic/storage", | ||
"version": "2.3.1", | ||
"description": "Ionic Storage utility", | ||
"version": "3.0.0-alpha.2", | ||
"description": "Ionic Storage Helper", | ||
"main": "dist/plugin.cjs.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"unpkg": "dist/plugin.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"author": "Ionic Team", | ||
"license": "MIT", | ||
"repository": { | ||
@@ -9,64 +18,28 @@ "type": "git", | ||
}, | ||
"keywords": [ | ||
"ionic", | ||
"angular", | ||
"localforage", | ||
"cordova", | ||
"hybrid" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ionic-team/ionic-storage/issues" | ||
}, | ||
"homepage": "https://github.com/ionic-team/ionic-storage#readme", | ||
"keywords": [ | ||
"capacitor", | ||
"plugin", | ||
"native" | ||
], | ||
"scripts": { | ||
"ts": "tsc", | ||
"build": "npm run clean && tsc && rollup -c rollup.config.js", | ||
"clean": "rimraf ./dist", | ||
"watch": "tsc --watch", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"dependencies": { | ||
"localforage": "1.7.1", | ||
"localforage-cordovasqlitedriver": "1.7.0", | ||
"tslib": "^1.10.0" | ||
"localforage": "^1.9.0" | ||
}, | ||
"peerDependencies": { | ||
"@angular/core": "*", | ||
"rxjs": "*" | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^17.1.0", | ||
"@rollup/plugin-node-resolve": "^11.2.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.40.0", | ||
"typescript": "^4.1.3" | ||
}, | ||
"$schema": "./node_modules/ng-packagr/package.schema.json", | ||
"release": { | ||
"branches": "stable", | ||
"pkgRoot": "dist", | ||
"verifyConditions": [ | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
"@semantic-release/github", | ||
"@semantic-release/git" | ||
], | ||
"prepare": [ | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
"@semantic-release/git" | ||
], | ||
"publish": [ | ||
"@semantic-release/github", | ||
"@semantic-release/npm" | ||
], | ||
"success": [ | ||
"@semantic-release/github" | ||
], | ||
"fail": [ | ||
"@semantic-release/github" | ||
] | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"main": "bundles/ionic-storage.umd.js", | ||
"module": "fesm5/ionic-storage.js", | ||
"es2015": "fesm2015/ionic-storage.js", | ||
"esm5": "esm5/ionic-storage.js", | ||
"esm2015": "esm2015/ionic-storage.js", | ||
"fesm5": "fesm5/ionic-storage.js", | ||
"fesm2015": "fesm2015/ionic-storage.js", | ||
"typings": "ionic-storage.d.ts", | ||
"metadata": "ionic-storage.metadata.json", | ||
"sideEffects": false | ||
"gitHead": "0b550acdc2d21c95c68e0655b28698ec60fa283a" | ||
} |
131
README.md
@@ -1,130 +0,1 @@ | ||
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fionic-team%2Fionic-storage%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/ionic-team/ionic-storage/goto?ref=main) | ||
# Ionic Storage | ||
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. | ||
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. | ||
If you want to perform arbitrary SQL queries and have one of the best storage options around, we recommend using the [Ionic Native SQLite plugin](https://ionicframework.com/docs/v2/native/sqlite/) directly. This engine no longer supports the `query` feature underneath as it was not portable and only worked for SQLite anyways. | ||
For those coming from Ionic pre RC.0, here is more insight in to the reason for us moving to this module: https://github.com/ionic-team/ionic/issues/8269#issuecomment-250590367 | ||
### Installation | ||
To use this in your Ionic /Angular apps, either start a fresh Ionic project which has it installed by default, or run: | ||
```bash | ||
npm install @ionic/storage | ||
``` | ||
If you'd like to use SQLite as a storage engine, install a SQLite plugin (only works while running in a simulator or on device): | ||
```bash | ||
cordova plugin add cordova-sqlite-storage --save | ||
``` | ||
### Usage | ||
Then edit your NgModule declaration in `src/app/app.module.ts` to add `IonicStorageModule` as an import: | ||
```typescript | ||
import { IonicStorageModule } from '@ionic/storage'; | ||
@NgModule({ | ||
declarations: [ | ||
... | ||
], | ||
imports: [ | ||
IonicModule.forRoot(MyApp), | ||
IonicStorageModule.forRoot() | ||
], | ||
bootstrap: [IonicApp], | ||
entryComponents: [ | ||
... | ||
], | ||
providers: [ | ||
... | ||
] | ||
}) | ||
export class AppModule { } | ||
``` | ||
Now, you can easily inject `Storage` into a component: | ||
```typescript | ||
import { Component } from '@angular/core'; | ||
import { Storage } from '@ionic/storage'; | ||
@Component({ | ||
selector: 'page-home', | ||
templateUrl: 'home.html' | ||
}) | ||
export class HomePage { | ||
constructor(private storage: Storage) { | ||
} | ||
} | ||
``` | ||
To make sure the storage system is ready before using, call `Storage.ready()`. You must be | ||
on 1.1.7 or greater to use the `ready()` method. | ||
```javascript | ||
storage.ready().then(() => { | ||
}); | ||
``` | ||
To set an item, use `Storage.set(key, value)`: | ||
```javascript | ||
this.storage.set('name', 'Mr. Ionitron'); | ||
``` | ||
To get the item back, use `Storage.get(name).then((value) => {})` since `get()` returns a Promise: | ||
```javascript | ||
this.storage.get('name').then((name) => { | ||
console.log('Me: Hey, ' + name + '! You have a very nice name.'); | ||
console.log('You: Thanks! I got it for my birthday.'); | ||
}); | ||
``` | ||
To remove the item, use `Storage.remove(key).then(() => { })` | ||
### Configuring Storage (new in 1.1.7) | ||
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 | ||
```typescript | ||
import { Storage } from '@ionic/storage'; | ||
@NgModule({ | ||
declarations: ..., | ||
imports: [ | ||
IonicStorageModule.forRoot({ | ||
name: '__mydb', | ||
driverOrder: ['indexeddb', 'sqlite', 'websql'] | ||
}) | ||
], | ||
bootstrap: ..., | ||
entryComponents: ..., | ||
}) | ||
export class AppModule { } | ||
``` | ||
### Development and release | ||
When you're ready to release a new version, run the following commands: | ||
1. npm version (patch|minor|major) | ||
2. npm run build | ||
3. commit and push: `git push origin master --tags` | ||
4. cd dist | ||
5. npm publish | ||
# Ionic Storage Helper |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
589759
1
5297
0
5
10
2
2
5
+ Addedlocalforage@1.10.0(transitive)
- Removedtslib@^1.10.0
- Removed@angular/core@18.2.10(transitive)
- Removedlocalforage@1.7.1(transitive)
- Removedlocalforage-cordovasqlitedriver@1.7.0(transitive)
- Removedrxjs@7.8.1(transitive)
- Removedtslib@1.14.12.8.1(transitive)
- Removedzone.js@0.14.10(transitive)
Updatedlocalforage@^1.9.0