fix: save uuid & nano id field value with sequelize validation (#3952)

This commit is contained in:
ChengLei Shao 2024-04-07 12:10:42 +08:00 committed by GitHub
parent 0bb421ac40
commit ac1e07ff52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 8 deletions

View File

@ -20,6 +20,7 @@ describe('uuid field', () => {
{
name: 'uuid',
type: 'uuid',
allowNull: false,
},
],
});

View File

@ -23,14 +23,12 @@ export class NanoidField extends Field {
bind() {
super.bind();
this.on('beforeCreate', this.listener);
this.on('beforeUpdate', this.listener);
this.on('beforeValidate', this.listener);
}
unbind() {
super.unbind();
this.off('beforeCreate', this.listener);
this.off('beforeUpdate', this.listener);
this.off('beforeValidate', this.listener);
}
}

View File

@ -21,14 +21,13 @@ export class UuidField extends Field {
bind() {
super.bind();
this.on('beforeCreate', this.listener);
this.on('beforeUpdate', this.listener);
// https://sequelize.org/docs/v6/other-topics/hooks/
this.on('beforeValidate', this.listener);
}
unbind() {
super.unbind();
this.off('beforeCreate', this.listener);
this.off('beforeUpdate', this.listener);
this.off('beforeValidate', this.listener);
}
}