Mongoose: add an example to the docs for transactions

Created on 5 Jul 2018  路  2Comments  路  Source: Automattic/mongoose

@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?

discussion docs

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.

All 2 comments

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().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeneser picture jeneser  路  3Comments

simonxca picture simonxca  路  3Comments

Igorpollo picture Igorpollo  路  3Comments

weisjohn picture weisjohn  路  3Comments

tarun1793 picture tarun1793  路  3Comments