@vkarpov15 should we link to your existing blog post from the docs for an example of transactions or can we steal it :smile: Should transactions have their own guide?
Just wondering, why is startSession
defined on the Model? I though that mongo supports multi collection transactions, so it feels a bit weird having to call it on a particular Model if a transaction is affecting multiple ones.
Yeah it is a little strange. We did that because with Mongoose you generally work with models, not connections, and we wanted to make the API convenient as possible. We added connection.startSession()
and mongoose.startSession()
in #6689, those will be in 5.2.2. But Model.startSession()
is just shorthand for Model.db.startSession()
.
Most helpful comment
Just wondering, why is
startSession
defined on the Model? I though that mongo supports multi collection transactions, so it feels a bit weird having to call it on a particular Model if a transaction is affecting multiple ones.