blow-data-service
v0.1.12
Published
Observable data service for Blow.
Downloads
6
Maintainers
Readme
blow-data-service
Observable data service for Blow.
How to install
npm install blow-data-service
Example
import {Observable} from 'rxjs';
import {Query, DataService} from 'blow-data-service';
const settings = {
default: {
default: true,
connector: 'memory'
}
}
const data = [{label: 'red', rgb: '#ff0000'}, {label: 'green', rgb: '#00ff00'}, {label: 'blue', rgb: '#0000ff'}];
DataService
.create(settings)
.connect()
.subscribe(dataService => {
const colorsCollection = dataService.collection('colors');
const query = new Query();
query.equal('label', 'red');
Observable.from(data)
.mergeMap(color => colorsCollection.save(color)) // save colors
.last()
.mergeMap(() => colorsCollection.delete(query)) // delete items via query
.mergeMap(() => colorsCollection.find()) // find all items
.subscribe(color => {
console.log(color); // log items to console
});
});
Connectors
- Memory
- MongoDB
Available methods
- count(query?: Query): Observable
- delete(query?: Query): Observable;
- deleteById(id: any): Observable;
- find(query?: Query): Observable;
- get(id: any): Observable;
- save(doc: Entity): Observable;