@creasource/ngx-idb
v0.1.0
Published
Angular module for @creasource/reactive-idb
Downloads
11
Readme
NgxIDB
An Angular module for reactive-idb.
Installation
npm i @creasource/ngx-idb @creasource/reactive-idb
yarn add @creasource/ngx-idb @creasource/reactive-idb
Basic Usage
Module import:
import { IndexedDBModule } from "@creasource/ngx-idb";
IndexedDBModule.forRoot({
name: 'myDatabase',
schema: [
{
version: 1,
stores: [
{
name: 'myStore',
options: { autoIncrement: true },
},
],
},
],
})
Service import:
import { Inject, Injectable } from "@angular/core";
import { IndexedDBService, Database } from "@creasource/ngx-idb";
@Injectable()
export class MyService {
constructor(@Inject(Database('myDatabase')) private database: IndexedDBService) {
database
.getStore<{ name: string }>('myStore')
.add({ name: 'John' })
.subscribe({
next: (key) => console.log(key),
error: (err) => console.error(err),
});
}
}
For more information see reactive-idb