import knexUtils from '@smpx/knex-utils';
import {Model} from 'xorm';
const knex = knexUtils.getKnex();
Model.knex(knex);
class Category extends Model {
async $afterUpdate(opts, queryContext) {
console.log('update'); // this is run
await super.$afterUpdate(opts, queryContext);
}
}
async function test() {
console.log(await Category.query().where('id', 999999).update({slug: 'abc'})); // prints 0, no rows were updated
}
test().catch((err) => {
console.error(err);
});
Working example: