Prerequisites
Issue
In $__handleSave() we have the following:
if (this.$isNew) {
// send entire doc
const obj = this.toObject(saveToObjectOptions);
However, if minimize: false, we don't need to run toObject(), we can just do const obj = this._doc because the MongoDB driver will clone and apply toBSON() anyway. This should significantly help performance.
Re: #8024, let's implement this functionality first and make sure it works as intended before considering making minimize default to false.
Prerequisites
Issue
In
$__handleSave()we have the following:However, if
minimize: false, we don't need to runtoObject(), we can just doconst obj = this._docbecause the MongoDB driver will clone and applytoBSON()anyway. This should significantly help performance.Re: #8024, let's implement this functionality first and make sure it works as intended before considering making
minimizedefault to false.