spencerlambert / mysql-events

A node meteor package that watches a MySQL database and runs callbacks on matched events.
Other
87 stars 74 forks source link

Listening to a specific column #7

Closed Arakiri closed 8 years ago

Arakiri commented 8 years ago

Hello,

I try to listen a specific column but I can't manage to make it work. It works fine when I only listen to a database or a table, tough. Here is my code :

`var MySQLEvents = require('mysql-events'); var dsn = { host: 'localhost', user: '_', password: '_', }; var mysqlEventWatcher = MySQLEvents(dsn);

//Fires when a match is started var newMatchStarted =mysqlEventWatcher.add( 'bot.matchs.status', function (oldRow, newRow) { console.log(newRow); console.log(oldRow); } );`

Thanks a lot!

spencerlambert commented 8 years ago

For columns, the current code only support value matches. Add the "value" tag and a third argument, like:

var event1 = myCon.add( 'dbName.tableName.fieldName.value', function(oldRow, newRow) { //code goes here }, 'Active' );

The third arg can also be a regex.

Thanks, Spence

On 02/20/2016 07:42 PM, Philippe SCHEID wrote:

Hello,

I try to listen a specific column but I can't manage to make it work. It works fine when I only listen to a database or a table, tough. Here is my code :

`var MySQLEvents = require('mysql-events'); var dsn = { host: 'localhost', user: '/', password: '/', }; var mysqlEventWatcher = MySQLEvents(dsn);

//Fires when a match is started var newMatchStarted =mysqlEventWatcher.add( 'bot.matchs.status', function (oldRow, newRow) { console.log(newRow); console.log(oldRow); } );`

Thanks a lot!

— Reply to this email directly or view it on GitHub https://github.com/spencerlambert/mysql-events/issues/7.

Arakiri commented 8 years ago

Thanks for the quick reply, nevetheless it doesn't seem to work neither