Open ggabrielCH opened 6 years ago
yes i have the same problem
@rodrigogs your fork doesn't solve any problems here, just has a different api. Multiple triggers only work if they are against the same table in the db. If they are different tables, the triggers seem to be ignored. A quick solution is to just create multiple instances for different tables, but it is very ugly. In reference to #32, I encounter the same problem on your fork. Having access to the connection doesn't really change anything. Keeping the connection alive should be handled in the library, not by the user.
Also, it would be nice if you would enable issues so that I don't have to post here.
What?
Man... you can add as many triggers as you want with my lib with no problem. Did you test it or are you just assuming?
About the issues. Thanks, I didn't realized that it was disabled.
@rodrigogs
This works:
instance.addTrigger({
name: 'Name1',
expression: 'schema.table1',
statement: MySQLEvents.STATEMENTS.INSERT,
callback: (event) => {
console.log(event)
}
});
instance.addTrigger({
name: 'Name2',
expression: 'schema.table1.column1',
statement: MySQLEvents.STATEMENTS.UPDATE,
callback: (event) => {
console.log(event)
}
});
This does not work:
instance.addTrigger({
name: 'Name1',
expression: 'schema.table1',
statement: MySQLEvents.STATEMENTS.INSERT,
callback: (event) => {
console.log(event)
}
});
instance.addTrigger({
name: 'Name2',
expression: 'schema.table1.column1',
statement: MySQLEvents.STATEMENTS.UPDATE,
callback: (event) => {
console.log(event)
}
});
// This breaks
instance.addTrigger({
name: 'Name3',
expression: 'schema.table2',
statement: MySQLEvents.STATEMENTS.INSERT,
callback: (event) => {
console.log(event)
}
});
Again, quick solution is to create a different instance, but its pretty ugly.
@ividrine fixed! https://github.com/rodrigogs/mysql-events/commit/8949adcdb0b4dc18bcb12b167b2a123f53e8905e
Thanks for spotting.
When you create many "watchers" to different tables (with add()), the first watched table works correctly but the other ones stop to work after around 10 minutes.
The changes on employees table are always catched, independently of the time there is no action on the table. The changes on accounts and bills tables are not catched anymore if there is no change for around 10 minutes.
If the order of mysqlEventWatcher.add is changed, then it's always the first table watcher who keep working.