Skip to content

Commit

Permalink
refactor: remove unnecessary condition and add clarifying comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 12, 2024
1 parent dc7966c commit 41b1ce3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ Model.prototype.$__handleSave = function(options, callback) {

const session = this.$session();
const asyncLocalStorage = this[modelDbSymbol].base.transactionAsyncLocalStorage?.getStore();
if (!saveOptions.hasOwnProperty('session') && session != null) {
if (session != null) {
saveOptions.session = session;
} else if (!options.hasOwnProperty('session') && asyncLocalStorage?.session != null) {
// Only set session from asyncLocalStorage if `session` option wasn't originally passed in options
saveOptions.session = asyncLocalStorage.session;
}
if (this.$isNew) {
Expand Down

0 comments on commit 41b1ce3

Please sign in to comment.