mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Models: Replace before.insert with autoValues
The before.insert hooks have the problem, that they are executed in a different order if called from the client or from the server. If called from the client, the before.insert hook is called before validation of the schema, but if called from the server, the validation is called first and fails.
This commit is contained in:
parent
14e2b3c15f
commit
a2888250f4
6 changed files with 129 additions and 75 deletions
|
|
@ -14,6 +14,11 @@ UnsavedEditCollection.attachSchema(new SimpleSchema({
|
|||
},
|
||||
userId: {
|
||||
type: String,
|
||||
autoValue() { // eslint-disable-line consistent-return
|
||||
if (this.isInsert && !this.isSet) {
|
||||
return this.userId;
|
||||
}
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
@ -28,7 +33,3 @@ if (Meteor.isServer) {
|
|||
fetch: ['userId'],
|
||||
});
|
||||
}
|
||||
|
||||
UnsavedEditCollection.before.insert((userId, doc) => {
|
||||
doc.userId = userId;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue