Closed
Description
opened on Feb 2, 2024
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Add withSession() function that would handle session's object lifetime. It should be analogous to the withTransaction() function.
For more details, see MongoDB driver documentation: https://mongodb.github.io/node-mongodb-native/6.3/classes/MongoClient.html#withSession
Motivation
There are two reasons why I believe withSession() function is required:
-
Ease of use
- Currently, to use a session, it is required to call two functions (startSession, endSessions) and handle any potential exceptions with a catch statement.
- It would be much more convenient for most use-cases to have this logic abstracted to an out-of-the-box function.
-
Consistency
- There already is withTransaction function that handles transaction lifecycle, so it is natural to expect there to be a similar function for the session object.
Example
No response
Activity