MongoDB - Start transaction
MongoDB - Start transaction
Starts a transaction session on a MongoDB connection. It lets you group several operations (insert, update, delete) into one atomic unit — every operation is applied together with MongoDB: Commit transaction or undone with MongoDB: Abort transaction.
Options
Connection
Reference to the MongoDB: Connection action the transaction will be started on.
Returns
Javascript code
js
actions["action-id"].session // session of the started transaction (Any)
Field selection
- session — transaction session, used as a reference by the operation actions that take part in the transaction (Any)
Rules and Conditions
- The Connection field is required.
- The returned session must be passed in the Transaction field of the operation actions (findMany, insertOne, updateMany, etc.) for them to take part in the transaction.
- The transaction must be finished with MongoDB: Commit transaction to apply the operations, or with MongoDB: Abort transaction to undo them.
- MongoDB requires the collections used in a transaction to exist before the transaction starts.