18.0.6 • Published 1 year ago

@ea-controls/ngrx-repository-pouchdb v18.0.6

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

repository-pouchDb

Extend @ea-controls/ngrx-repository for using local pouchdb database storage in localStorage.

ngrx official documentation

@ea-controls/ngrx-repository

pouchDb

Installation

npm i @ea-controls/ngrx-repository-pouchdb@latest

Configuration

Follow the same configuration steps as @ea-controls/ngrx-repository. Afterward, configure the web API effects:

Register in app.config.ts (standalone components) the following code

import { EntityAdapter } from "@ea-controls/ngrx-repository";
import { provideRepositoryPouchDb } from "@ea-controls/ngrx-repository-pouchdb";

export const userAdapter = new EntityAdapter<UserEntity>("items", { additionalData: 'userId' } );

export const appConfig: ApplicationConfig = {
  providers: [
    ...
    provideRepositoryPouchDb({
      adapters: [userAdapter], // <-- Add your adapters
      getIdField: (adapter) => adapter.options.additionalData?.id // <-- Default id field
      ... // <-- Other options
    })
  ],
};

Usage

Follow the same usage instructions as @ea-controls/ngrx-repository.

Note: For fetching data for the first time, you should call the getAll() method manually.

@Component({...})
export class RepositoryComponentWrap implements OnInit {
    
    constructor(private store: Store) { }

    ngOnInit(): void {
        this.store.dispatch(userAdapter.getAll());
    }
}

provideRepositoryPouchDb Options

Configure @ea-controls/ngrx-repository-pouchdb for flexible data transformation and URL formats.

OptionDescriptionInputOutput
additionalDataany additional data you want in the entity adapterany-
getDbCallback for building PouchDb instanceEntityAdapterReturns new instance of PouchDb, if you extend this consider caching your db instances
18.0.6

1 year ago

18.0.5

1 year ago

18.0.4

1 year ago

18.0.3

1 year ago

18.0.2

1 year ago

18.0.1

1 year ago