-
|
Setting // Global
mongoose.set('transactionAsyncLocalStorage', true);
// Service 1
userTransaction = mongoose.connection.transaction("..transaction code")
// Service 2
otherTransaction = mongoose.connection.transaction("...transaction code")Would mongoose will automatically make sure that sessions would be passed but it wouldn't collide with other transactions (i.e. if first transaction fails, it wouldn't roll back second transaction) |
Beta Was this translation helpful? Give feedback.
Answered by
vkarpov15
Sep 25, 2024
Replies: 1 comment 2 replies
-
|
bumping up! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is more of a MongoDB server question, but if the first transaction fails then the 2nd transaction shouldn't get rolled back unless it conflicts with another transaction. Mongoose's
transaction()function starts a new session every time. Does that help?