Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var MySQLEvents = require('mysql-events');
  2. var dsn = {
  3. host: "localhost",
  4. user: "root",
  5. password: "password",
  6. port: "3306",
  7. };
  8. var mysqlEventWatcher = MySQLEvents(dsn);
  9. var watcher = mysqlEventWatcher.add(
  10. 'schema1.test',
  11. function (oldRow, newRow, event) {
  12. //row inserted
  13. if (oldRow === null) {
  14. //insert code goes here
  15. console.log("ROW INSERT: ", newRow.fields);
  16. }
  17.  
  18. //row deleted
  19. if (newRow === null) {
  20. //delete code goes here
  21. console.log("ROW DELETED");
  22. }
  23.  
  24. //row updated
  25. if (oldRow !== null && newRow !== null) {
  26. //update code goes here
  27. console.log("ROW UPDATE ---->", newRow);
  28. }
  29.  
  30. //detailed event information
  31. // console.log(event)
  32. },
  33. 'match this string or regex'
  34. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement