I am new in node.js. I was just trying to build a module to track a record for all MySQL database activity with details using node.js. as I want like someone insert/update/delete in MySQL db then data will show in our node console. example- database my_work insert a row with value (......) when I hit a insert command in MySQL workbench.
Asked
Active
Viewed 536 times
0
-
1Hi there - could you perhaps post some code to let us know what you have tried so far? To be clear, what you are looking for is an event listener for your MySQL instance that feeds up to your node server, rather than implementing database calls from node itself? – Marcus Jan 29 '18 at 09:40
-
So far I installed one module in node named as mysql-events – Sumit Sharma Jan 29 '18 at 10:04
-
var MySQLEvents = require('mysql-events'); var dsn = { host: 'localhost', user: 'my_work', password: 1234, }; var mysqlEventWatcher = MySQLEvents(dsn); var watcher =mysqlEventWatcher.add( 'myDB.table.field.value', function (oldRow, newRow, event) { //row inserted if (oldRow === null) { } //row deleted if (newRow === null) { } //row updated if (oldRow !== null && newRow !== null) { //update code goes here } }, ); – Sumit Sharma Jan 29 '18 at 10:06