Skip to content

Commit

Permalink
Adding session support
Browse files Browse the repository at this point in the history
If the document is associated with a session, run the count query in that session as well.
  • Loading branch information
makinde committed Apr 23, 2020
1 parent 36e63b3 commit 7067339
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/id-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ function validateId (
}
var refModel = connection.model(refModelName)
var query = refModel.countDocuments({_id: value})
var session = doc.$session && doc.$session()
if (session) {
query.session(session)
}
executeQuery(query, conditions, 1, resolve, reject)
}

Expand All @@ -140,6 +144,10 @@ function validateIdArray (

var refModel = connection.model(refModelName)
var query = refModel.countDocuments().where('_id')['in'](checkValues)
var session = doc.$session && doc.$session()
if (session) {
query.session(session)
}

executeQuery(query, conditions, checkValues.length, resolve, reject)
}
Expand Down

0 comments on commit 7067339

Please sign in to comment.