We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b8c4a1e commit c7cc77dCopy full SHA for c7cc77d
lib/model.js
@@ -358,11 +358,11 @@ Model.prototype.$__handleSave = function(options, callback) {
358
if (this.$isNew) {
359
// send entire doc
360
let obj;
361
- if (this.$__schema.options.minimize === false) {
362
- obj = this._doc;
363
- } else {
364
- obj = this.toObject(saveToObjectOptions);
365
- }
+ // Always use toObject for serialization; control minimize via options
+ saveToObjectOptions = Object.assign({}, saveToObjectOptions, {
+ minimize: this.$__schema.options.minimize
+ });
+ obj = this.toObject(saveToObjectOptions);
366
if ((obj || {})._id === void 0) {
367
// documents must have an _id else mongoose won't know
368
// what to update later if more changes are made. the user
0 commit comments