Skip to content

Commit

Permalink
fix(document): allow setting nested path to instance of model
Browse files Browse the repository at this point in the history
Fix #9392
  • Loading branch information
vkarpov15 committed Sep 9, 2020
1 parent 61885f2 commit c5294c3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/helpers/document/compile.js
Expand Up @@ -2,6 +2,7 @@

const documentSchemaSymbol = require('../../helpers/symbols').documentSchemaSymbol;
const get = require('../../helpers/get');
const internalToObjectOptions = require('../../options').internalToObjectOptions;
const utils = require('../../utils');

let Document;
Expand Down Expand Up @@ -142,6 +143,8 @@ function defineKey(prop, subprops, prototype, prefix, keys, options) {
// Convert top-level to POJO, but leave subdocs hydrated so `$set`
// can handle them. See gh-9293.
v = v.$__parent.get(path);
} else if (v instanceof Document && !v.$__isNested) {
v = v.toObject(internalToObjectOptions);
}
const doc = this.$__[scopeSymbol] || this;
doc.$set(path, v);
Expand Down

0 comments on commit c5294c3

Please sign in to comment.