mysql-events icon indicating copy to clipboard operation
mysql-events copied to clipboard

Listens to multiple changes?

Open jyzhao opened this issue 8 years ago • 3 comments
trafficstars

I just want to double check if mysql-events supports monitoring multiple changes? For example, what happens if I do bulk insert/delete/update to the tables?

jyzhao avatar Jul 19 '17 16:07 jyzhao

It should work. I haven't done extensive testing with that use case. Please test it out and report back. Thanks!

spencerlambert avatar Jul 19 '17 18:07 spencerlambert

Hi, I am writing a script to update a table.

Eg : I run a script to update 2 rows in a table

In node.js, my code is in the following way :

var dsn = {
  host:     'hostname',
  user:     'user',
  password: 'password',
  port     : '8080',
};
var mysqlEventWatcher = MySQLEvents(dsn);
var watcher =mysqlEventWatcher.add(
  'databse.table',
  function (oldRow, newRow, event) {
     //row inserted
console.log("Inside watcher");
//console.log(event);
console.log(event);
    if (oldRow === null) {
      //insert code goes here
    }
     //row deleted
    if (newRow === null) {
      //delete code goes here
    }
     //row updated
    if (oldRow !== null && newRow !== null) {
      //update code goes here
    }
	}
  }
);

The watcher is called two times .. and in both watchers the updated rows are shown. Please help !

anusha9213 avatar Nov 16 '17 11:11 anusha9213

https://github.com/rodrigogs/mysql-events

rodrigogs avatar Jun 27 '18 20:06 rodrigogs