0

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){

  }

1 Answers1

0

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
}
Barmar
  • 741,623
  • 53
  • 500
  • 612
Bergur
  • 3,962
  • 12
  • 20