Skip to content
Advertisement

Check for changes in MySQL, node.js

How can I, in this code, take the data that has been changed in MYSQL and return it in another function? For example, take the id_ticket column and use it in another function.

    const instance = new MySQLEvents(connection, {
      startAtEnd: true
    });
  
    await instance.start();
  
    instance.addTrigger({
      name: 'monitoring all statments',
      expression: config.MYSQL_DATABASE+'.ticket.*',
      statement: MySQLEvents.STATEMENTS.ALL,
      onEvent: e => {
        //Take column "id_ticket"
      }
    });
  
    instance.on(MySQLEvents.EVENTS.CONNECTION_ERROR, console.error);
    instance.on(MySQLEvents.EVENTS.ZONGJI_ERROR, console.error);
  };
  function idticket(//take "id_ticket" from event){

  }

Advertisement

Answer

onEvent is a handler, you just need to pass a function to that handler

onEvent: handler

and

function handler(event) {
  console.log('event', event)
  // do some more
}
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement