geyser-mongo
v1.0.0-beta.1
Published
Publish and subscribe to streams of data over MongoDB
Downloads
6
Readme
Geyser
Publish and subscribe to streams of data over MongoDB.
Usage
Source Node.js process:
import { Observable } from 'rxjs';
import { MongoObserver } from 'geyser-mongo';
// Create an Observer which writes to a 'ticks' collection in MongoDB
const ticks = MongoObserver.connect({
url: 'mongodb://localhost/my-db',
collection: 'ticks'
})
// Subscribe our "ticks" observer to a stream
Observable.interval(1000).subscribe(ticks);
Listening Node.js process:
import { MongoObservable } from 'geyser-mongo';
// create a
const ticks = MongoObservable.connect({
url: 'mongodb://localhost/my-db',
collection: 'ticks'
})
// Subscribe to the "ticks" stream
ticks.subscribe(console.log);
// 1
// 2
// 3
// ...