Socket
Socket
Sign inDemoInstall

ngx-dexie-observable

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-dexie-observable

Dexie module for Angular 2.0+


Version published
Weekly downloads
5
Maintainers
1
Install size
1.75 MB
Created
Weekly downloads
 

Readme

Source

ngx-dexie-observable

Dexie module for Angular 2.0+ projects

This is a fork of ngx-dexie with rxjs observable implementation

Install

npm install ngx-dexie-observable --save

How to use

Import and configure DexieModule

//...
import { DexieModule, DexieConfig } from 'ngx-dexie';

const config: DexieConfig = {
    databaseName: 'AppDatabase',//your database name here
    schema: {
        friends: '++id, first_name, last_name',
        teachers: '++id, first_name, last_name'
    } // any schema of your choice
};

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DexieModule.forRoot(config)
    ],
    providers: [

    ],
    bootstrap: [AppComponent]
})

export class AppModule { }

Using your dexie instance

The DexieModule provides now a configured Dexie db instance and a Dexie db service, i.e. DexieService which can be injected anywhere inside the AppModule.

import { Injectable } from '@angular/core';
import { DexieService } from 'ngx-dexie';

@Injectable()
export class IndexedDbService {

    constructor(private dexieService: DexieService) {}

    addOneFriend(friendObject: Object) {
        this.dexieService.addOne('friends', friendObject);
    }

}

API

dexieService.addOne(table: string, object: Object)

Adds the entry object to the dexie table table Returns a promise which when resolved gives the key of the object added, when rejected gives the error that occured.

dexieService.addMultiple(table: string, objects: Object[])

Adds multiple objects to the dexie table table Returns a promise which works similar to Dexie bulkAdd()

dexieService.count(table: string)

Returns a promise which when resolved gives the number of objects in the table table

dexieService.addOrUpdateOne(table: string, object: Object, key?: any)

Works similar to Dexie put()

dexieService.addOrUpdateMultiple(table: string, objects: Object[], keys?: any)

Works similar to Dexie bulkPut()

dexieService.deleteOne(table: string, primaryKey: any)

Works similar to Dexie delete()

dexieService.deleteMultiple(table: string, primaryKeys: any[])

Works similar to Dexie bulkDelete()

dexieService.clearAll(table: string)

Works similar to Dexie clear()

dexieService.operateOnEach(table: string, callback: (item: any, idbCursor: any) => any)

Works similar to Dexie each()

dexieService.filter(table: string, filterFunction: (value: any) => boolean)

Works similar to Dexie filter()

dexieService.getByPrimaryKey(table: string, primaryKey: any, callback?: (item: Object) => any)

Works similar to Dexie get()

dexieService.getByKeyToValueMap(table: string, keyValueMap: Object, callback?: (item: Object) => any)

Works similar to Dexie get()

dexieService.getFirstNItemsOfTable(table: string, num: number)

Works similar to Dexie limit()

dexieService.orderBy(table: string, index: string)

Works similar to Dexie orderBy()

dexieService.offset(table: string, ignoreUpto: number)

Works similar to Dexie offset()

dexieService.reverse(table: string)

Works similar to Dexie reverse()

dexieService.toArray(table: string, callback?: (objects: Object[]) => any)

Works similar to Dexie toArray()

dexieService.toCollection(table: string)

Works similar to Dexie toCollection()

dexieService.update(table: string, key: any, changes: Object)

Works similar to Dexie update()

Keywords

FAQs

Last updated on 13 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc