📌  相关文章
📜  制作一个套接字服务器来检测mysql代码示例中的变化

📅  最后修改于: 2022-03-11 15:05:06.084000             🧑  作者: Mango

代码示例1
var MySQLEvents = require('mysql-events');
var dsn = {
  host:     _dbhostname_,
  user:     _dbusername_,
  password: _dbpassword_,
};
var mysqlEventWatcher = MySQLEvents(dsn);
var watcher =mysqlEventWatcher.add(
  'myDB.table.field.value',
  function (oldRow, newRow, event) {
     //row inserted 
    if (oldRow === null) {
      //insert code goes here 
    }

     //row deleted 
    if (newRow === null) {
      //delete code goes here 
    }

     //row updated 
    if (oldRow !== null && newRow !== null) {
      //update code goes here 
    }

    //detailed event information 
    //console.log(event) 
  }, 
  'match this string or regex'
);