mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
14 lines
351 B
JavaScript
14 lines
351 B
JavaScript
|
|
||
|
module.exports = (db) => {
|
||
|
for (const modelName of Object.keys(db)) {
|
||
|
const model = db[modelName];
|
||
|
|
||
|
model.beforeCreate('increment-version-c', (instance) => {
|
||
|
instance.version = 1;
|
||
|
});
|
||
|
model.beforeUpdate('increment-version-u', (instance) => {
|
||
|
instance.version = instance.version ? instance.version + 1 : 1;
|
||
|
});
|
||
|
}
|
||
|
}
|