Closed happilymarrieddad closed 8 years ago
Here is my connection code
var MySQLEvents = require('mysql-events')
var dsn = {
host : process.env.DB_HOST,
user : process.env.DB_USERNAME,
password : process.env.DB_PASSWORD
}
var mysqlEventWatcher1 = MySQLEvents(dsn)
var watcher1 = mysqlEventWatcher1.add(
process.env.DB_DATABASE,
function(oldRow,newRow) {
// Insert
// if (oldRow === null) {
// console.log('')
// console.log('Insert')
// console.log(oldRow)
// console.log(newRow)
// console.log('')
// }
// // Deleted
// if (newRow === null) {
// console.log('')
// console.log('Deleted')
// console.log(oldRow)
// console.log(newRow)
// console.log('')
// }
// // Updated
// if (oldRow !== null && newRow !== null) {
// console.log('')
// console.log('Updated')
// console.log(oldRow)
// console.log(newRow)
// console.log('')
// }
console.log('')
console.log('')
console.log(oldRow)
console.log(newRow)
console.log('')
console.log('')
}
)
Can you please check your query again? It looks like an update calls o/p, changing the "visibility" from 1 => 0
I don't think your database is doing an actual delete. If you look in index.js you'll find that newRow is explicitly set to null, when getting the delete message from the db.
if (evt.getEventName() == 'deleterows') {
newRow = null;
oldRow = {
database: database,
table: table,
affectedColumns: columns,
changedColumns: changedColumns,
fields: row
};
}
ah yes... lol thanks... it happened to be that table does a logical delete... sorry I didn't catch that. Thanks!
Hi, I was reading the docs and the docs say that the delete should have the newRow === null but here is the dump from a delete. I'm using "mysql-events" : "0.0.7" (I just did a npm install mysql-events --save). I really need this to work and I appreciate any help you can provide. Thanks!