Skip to content

Observe MongoDB collections and emit events to Redis (for MyDB)

License

Notifications You must be signed in to change notification settings

Automattic/mydb-observer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyDB Observer

Observes MongoDB Collection objects, publishes write events to Redis for MyDB.

Compatibility

For compatible node, mongodb and redis versions, please check the peerDependencies field in package.json.

Usage

"use strict";

const mongodb = require('mongodb');
const redis = require('redis');
const MyDBObserver = require('mydb-observer');

let redisClient = redis.createClient();
let observer = new MyDBObserver(redisClient);

mongodb.MongoClient
  .connect('mongodb://localhost')
  .then(db => {
    let foo = db.collection('foo');
    observer.observe(foo);

    // changes will be published to Redis, for MyDB
    foo.update(/* ... */);
  });

About

Observe MongoDB collections and emit events to Redis (for MyDB)

Resources

License

Stars

Watchers

Forks

Packages

No packages published