Skip to content

platdesign/mongo-oplog-observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#mongo-oplog-observable

Creates an observable from a mongodb-oplog.

Install

npm install --save mongo-oplog-observable

Usage

OplogObservable(config)

  • config.uri [String] mongodb connection-string
  • config.ns [String] database, database.*, *.database, (databaseA|databaseB), database.collection, (db|dbX|dbY)$, etc.

Examples

var OplogObservable = require('mongo-oplog-observable');

var oplog = OplogObservable({
	uri: 'mongodb://127.0.0.1:12345/local', 
	ns: 'myDatabase.myCollection'
});

var inserts = oplog.filter(function(e){ return e.op === 'i'; });
var updates = oplog.filter(function(e){ return e.op === 'u'; });
var deletes = oplog.filter(function(e){ return e.op === 'd'; });

oplog.subscribe(
	function onNext(event){
		console.log('Next');
		console.log(event);
	},
	function onError(err){
		console.log('Error');
		console.log(err);
	},
	function onCompleted() {
		console.log('Completed');
	}
);

#Author

Christian Blaschke [email protected]

About

Creates an observable from a mongodb-oplog

Resources

Stars

Watchers

Forks

Packages

No packages published