Whenever I tried to
console mysqlEventWatcher.coonect()
It throws the following error
if (!_underScore.isUndefined(dsn.host) && ^ TypeError: Cannot read property 'host' of undefined at Object.connect (/Public_Nodejs/node_modules/mysql-events/index.js:64:39)
But I defined my dsn object.
Here is my dsn object
var db_config = {
host : 'localhost',
user : 'root',
password : 'password',
}
var MySQLEvents = require('mysql-events');
var dsn = {
host: db_config.host,
user: db_config.user,
password: db_config.password
};
var mysqlEventWatcher = MySQLEvents(dsn);
console.log(mysqlEventWatcher);
console.log('Before SqlWatcher');
var watcher =mysqlEventWatcher.add(
'mydb.mttable1',
// 'myDB.table.field.value',
function (oldRow, newRow, event) {
console.log('Hello'+'i am in sqlWatcher');
//row inserted
if (oldRow === null) {
//console('insert code goes here');
}
//row deleted
if (newRow === null) {
//delete code goes here
}
//row updated
if (oldRow !== null && newRow !== null) {
//update code goes here
}
//detailed event information
console.log(event)
},
'Active'
);
via VIKAS KOHLI
No comments:
Post a Comment