GithubHelp home page GithubHelp logo

mongo-trigger's Introduction

Mongo Stream

Listening to MongoDB live changes using mongo-oplog.

This is intended to replace deprecated mongo-watch and increase its features.

Install

npm install mongo-trigger

Usage

Watching a collection is as easy as:

var MongoStream = require('mongo-trigger');

var watcher = new MongoStream({format: 'pretty'});

// watch the collection
watcher.watch('test.users', function(event) {
  // parse the results
  console.log('something changed:', event);
}

Options

See the applyDefaults function in lib/index.js for a list of options and their defaults.

Authentication

Pass the "username" and "password" options (and authDB in case it is different to 'admin')

var watcher = new MongoStream({username: 'bobross', password: 'happytrees', authdb:'admin'});

Replica sets

If you pass a replicaSet array it will be used to establish a connection. It should keep working in case the primary changes - i.e. when it dies, and secondary takes it place.

var watcher = new MongoStream({
    replicaSet: [
        {host: "currentPrimary.mongoexample.com", port : 10453},
        {host: "currentSecondary.mongoexample.com", port : 10452}
    ]
});

MongoS

I am currently working on supporting connections to MongoS. In this case, this driver will obtain all replicaSets forming the cluster and watch to each shard. This feature will be available in future versions (any help will be very welcome).

Credits

TorchlightSoftware inspired this project with its mongo-watch module. This couldn't be possible without cayasso's mongo-oplog module.

Contributing

Pull requests welcome! Please create a feature branch instead of submitting directly to master. This will help me test/verify before merging.

mongo-trigger's People

Contributors

afharo avatar

Stargazers

Patrick Luzolo avatar Valter Negreiros avatar Enquan Chen avatar Jaffar Cardoso avatar GARCIA Guillaume avatar Websites.ca Web Design avatar Allan Galera Teixeira avatar wxz avatar Colton Colcleasure avatar Manu Rueda avatar Yassine A. avatar denistsoi avatar Renan Bastos avatar Raghunandan Rajput avatar Satrio Wisnugroho avatar  avatar Arnold Stoba avatar Alin Alexa avatar Roman Pearah avatar Efstathios Ntonas avatar Shmuli avatar John Cragun avatar liuyanghejerry avatar Mario C. Costa Junior avatar Bachue Zhou avatar Praveen Sastry avatar Andrei Botezatu avatar

Watchers

James Cloos avatar Patrick Luzolo avatar Raghunandan Rajput avatar  avatar

mongo-trigger's Issues

no action

an insert is made to posts
it shows on the db.oplog.$main.count()

yet no action ?

oplog.$main does show any change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.