Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$afterUpdate should only run if any row is actually updated #16

Open
parul157 opened this issue Dec 18, 2018 · 0 comments
Open

$afterUpdate should only run if any row is actually updated #16

parul157 opened this issue Dec 18, 2018 · 0 comments
Labels

Comments

@parul157
Copy link

Working example:

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);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants