-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new featureThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Description
I have read the two discussions (#2571 and #517) that relate to this opportunity, and still do not see any reason to abandon it. Why not? Even if Mongoose should maintain compatibility with the ES5, this does not prevent to check that the setter returns to us. Watch this pseudo-code:
if (setterResult.constructor.name === 'Promise' && setterResult.then) {
promisesArray.push(setterResult.then(
value => {
return {
path: path,
value: value
};
},
err => {
return err;
}
));
}
// ...
if (promisesArray.length){
return Promise.all(promisesArray).then(
results => {
for (let result of results) {
// Do anything with it
}
// Do anything with all fields
return this.save();
},
errors => {
for (let err of errors) {
// Do anything with it
}
return errors;
}
);
} else {
// Do anything with all fields
return this.save();
}So why not? This is a very useful feature, and it will join naturally in existing.
Xenya0815, mrpinkcat, thebrucecgit, lvkins, AlexRMU and 1 more
Metadata
Metadata
Assignees
Labels
enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new featureThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature