I just completed the installation of mongo-triggers by running:
npm install mongo-triggers
Now, I'm attempting to set up a simple "hello world" example:
var MongoClient = require('mongodb').MongoClient;
var triggers = require("mongo-triggers");
MongoClient.connect('mongodb://localhost:27017/mydatabase', function(err, db) {
triggers(db.mycollection).insert(function(document, next) {
console.log("Triggered on insert");
next();
});
});
But when I try to run it, I encounter this error message:
TypeError: Cannot read property 'save' of undefined
As I'm not very familiar with JavaScript, I may have overlooked something. Any assistance would be greatly appreciated.