simple-rx-pouchdb
v1.0.2
Published
simple rx wrapper for pouch db that merges changes into lookup method streams
Downloads
4
Readme
simple-rx-pouchdb
You might need to do some setup on your pouch db, local/remote replicate etc.
I usually check if the remote is up first, once you have it you can pass it into the
class SimpleRxPouch that has a constructor definition: constructor(public pouch: Observable<PouchDB>)
It assumes the pattern of pouch db per entity collection where all entities extend the interface
{ _id: string }
getPouchDB(): Observable<PouchDB>;
listenForChangesOnEntity(_id: string): Observable<any>;
listenForChangesOnEntities(): Observable<any>;
/**
* Gets all entities
*
* @returns Observable<T[]> all entities
*/
getAllEntities<T>(): Observable<T[]>;
/**
* Gets one entity
*
* @param _id
* @returns Observable<T> one entity
*/
getOneEntity<T>(_id: string): Observable<T>;
/**
* Updates entity
*
* @param entityPartial
* @returns Observable<boolean> success
*/
updateEntity<T>(entityPartial: Partial<T>): Observable<boolean>;
/**
* Creates entity
*
* @param entityPartial
* @returns Observable<boolean> success
*/
createEntity<T>(entityPartial: Partial<T>): Observable<boolean>;
/**
* Watches all
*
* @returns Observable<T[]> all
*/
watchAll<T>(): Observable<T[]>;
/**
* Watches id
*
* @param id
* @returns Observable<T>
*/
watchId<T>(id: string): Observable<T>;
/**
* Find and watch result set
*
* @param [selector]
* @param [sort]
* @param [fields]
* @returns Observable<T[]> result set
*/
findAndWatch<T>(selector: any, sort?: string[], fields?: string[]): Observable<T[]>;