1.1.0 • Published 10 years ago

oplog-transform-tail v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

build status #Oplog Transform Tail Tail the MongoDB oplog and update a secondary store in real time

##About

This is just a combination of oplog-transform and mongo-oplog to make a seemless tool for tailing the MongoDB oplog and performing the changes on a secondary store.

##Usage

var tail = require('oplog-transform-tail')
  
tail({
  url: "mongodb://127.0.0.1:27017/local", //optional

  //Function to call when an insert occurs
  insert: function(_id, doc, cb) {
    /* insert doc */
    cb()
  },
    
  //Function to call when an update occurs
  update: function(_id, done){
    var retrievedDoc = /* fetch doc from your secondary store */
    done(retrievedDoc, function(err, updatedDoc, cb) {
      /* store updated doc */
      cb()
    })
  },

  //Function to call when an delete occurs
  remove: function(_id, cb) {
    /* delete doc */
    cb()
  }
})

See the oplog-transform docs for more in-depth info about how the insert, update, and remove hooks work.


Made with ⚡️ by @taterbase