Skip to content

derme302/localforage-capacitorsqlitedriver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

localForage Capacitor SQLite Driver

A custom localForage driver using @capacitor-community/sqlite for Ionic Storage. Designed to be a drop in replacement for localforage-cordovasqlitedriver.

Install and Use

npm install @derme302/localforage-capacitorsqlitedriver
import { CAPACITOR_SQLITE_DRIVER } from '@derme302/localforage-capacitorsqlitedriver';

bootstrapApplication(AppComponent, {
  providers: [
    {
    importProvidersFrom(IonicStorageModule.forRoot({
      driverOrder: [CAPACITOR_SQLITE_DRIVER, Drivers.IndexedDB, Drivers.LocalStorage]
    }))
});

Then use Storage as usual.

import { Storage } from '@ionic/storage-angular';
import { SQLiteDriver } from '@derme302/localforage-capacitorsqlitedriver';

export class StorageService {
  public isReady: boolean = false;
  private _storage: Storage | null = null;

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

  async init() {
    await this.storage.defineDriver(new SQLiteDriver());
    const storage = await this.storage.create();
    this._storage = storage;
    this.isReady = true;
  }
}

🛠 Build the Package

npm install
npm run build

This generates the dist/ folder.

About

Custom Ionic Storage driver using @capacitor-community/sqlite

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published