Closed leopucci closed 2 years ago
Hi @leopucci,
db.register()
is not a valid function anymore. You're looking for db.function()
. Always doublecheck with the API documentation.
Thank you man, you are the best. I saw the function in the documentation but wasn´t sure if it was the same.
db.function('logger', { varargs: true }, function logger(...values) {
console.log(`TESTE row updated to (${values.join(', ')})`);
});
db.prepare('DROP TRIGGER IF EXISTS updateHook;').run();
db.prepare(
'CREATE TRIGGER updateHook AFTER UPDATE ON files BEGIN SELECT logger(NEW.a,NEW.b); END'
).run();
It works
I was trying to set a hook like sqlite3_update_hook and found this way of doing using db.register and triggers
But i was unable to use.
TypeError: db.register is not a function
Any hints on how update hooks can be created?https://github.com/JoshuaWise/better-sqlite3/issues/62#issuecomment-325797335