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

Multi table Watcher with MysqlEvents ? #40

Closed Crysis419 closed 6 years ago

Crysis419 commented 6 years ago

Hi guys, Happy New Year 2018

Can i listen multi table with MysqlEvent ?

let watcher =mysqlEventWatcher.add( 'database.tablesname', ...

I would add a second tables , how to do this ?

thx

elsuxo commented 6 years ago

You can add more watchers by calling mysqlEventWatcher.add(...); again

for example:

mysqlEventWatcher.add(
        'database.table1',
        eventCallback
);

mysqlEventWatcher.add(
        'database.table2',
        eventCallback
);
iviewproject commented 6 years ago

can someone explain how it works?

spencerlambert commented 6 years ago

@iviewproject The .add() call pushes the table name and callback function onto a stack.

https://github.com/spencerlambert/mysql-events/blob/master/index.js#L76-L93

That's how it works.