Skip to content

Commit

Permalink
fix(document): use associated session $session() when using `doc.po…
Browse files Browse the repository at this point in the history
…pulate()`

Fix #6754
  • Loading branch information
vkarpov15 committed Jul 27, 2018
1 parent 28621a5 commit 88457b0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/document.js
Expand Up @@ -2757,6 +2757,17 @@ Document.prototype.populate = function populate() {
populateOptions.path = nestedPath + '.' + populateOptions.path;
});
}

// Use `$session()` by default if the document has an associated session
// See gh-6754
if (this.$session() != null) {
const session = this.$session();
paths.forEach(path => {
path.options = path.options || {};
path.options.session = session;
});
}

topLevelModel.populate(this, paths, fn);
}

Expand Down

0 comments on commit 88457b0

Please sign in to comment.