Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed May 11, 2024
1 parent 2df8f37 commit f498cc5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Model.prototype.$__handleSave = function(options, callback) {
}

const session = this.$session();
const asyncLocalStorage = this.db.base.transactionAsyncLocalStorage?.getStore();
const asyncLocalStorage = this[modelDbSymbol].base.transactionAsyncLocalStorage?.getStore();
if (!saveOptions.hasOwnProperty('session') && session != null) {
saveOptions.session = session;
} else if (asyncLocalStorage?.session != null) {
Expand Down Expand Up @@ -3537,7 +3537,7 @@ Model.bulkWrite = async function bulkWrite(ops, options) {

const validations = ops.map(op => castBulkWrite(this, op, options));
const asyncLocalStorage = this.db.base.transactionAsyncLocalStorage?.getStore();
if (!options.hasOwnProperty('session') && asyncLocalStorage.session != null) {
if ((!options || !options.hasOwnProperty('session')) && asyncLocalStorage?.session != null) {
options = { ...options, session: asyncLocalStorage.session };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ Query.prototype._optionsForExec = function(model) {
// Apply schema-level `writeConcern` option
applyWriteConcern(model.schema, options);

const asyncLocalStorage = this.model.db.base.transactionAsyncLocalStorage?.getStore();
const asyncLocalStorage = this.model?.db?.base.transactionAsyncLocalStorage?.getStore();
if (!this.options.hasOwnProperty('session') && asyncLocalStorage?.session != null) {
options.session = asyncLocalStorage.session;
}
Expand Down

0 comments on commit f498cc5

Please sign in to comment.