Skip to content

Commit 88457b0

Browse files
committedJul 27, 2018
fix(document): use associated session $session() when using doc.populate()
Fix #6754
1 parent 28621a5 commit 88457b0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎lib/document.js

+11
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,17 @@ Document.prototype.populate = function populate() {
27572757
populateOptions.path = nestedPath + '.' + populateOptions.path;
27582758
});
27592759
}
2760+
2761+
// Use `$session()` by default if the document has an associated session
2762+
// See gh-6754
2763+
if (this.$session() != null) {
2764+
const session = this.$session();
2765+
paths.forEach(path => {
2766+
path.options = path.options || {};
2767+
path.options.session = session;
2768+
});
2769+
}
2770+
27602771
topLevelModel.populate(this, paths, fn);
27612772
}
27622773

0 commit comments

Comments
 (0)
Please sign in to comment.