- Reference >
- Database Commands >
- Sessions Commands >
- commitTransaction
commitTransaction¶
On this page
Definition¶
-
commitTransaction¶ New in version 4.0.
Saves the changes made by the operations in the multi-document transaction and ends the transaction. Until the commit, none of the data changes made from within the transaction are visible outside the transaction.
To run the
commitTransaction, the command must be run against theadmindatabase and run within aSession. Rather than run thecommitTransactioncommand directly, most users should use the driver method or themongoshellSession.commitTransaction()helper.The command has the following syntax:
Behavior¶
Write Concern¶
When committing the transaction, the session uses the write concern
specified at the transaction start. See
Session.startTransaction().
If you commit using "w: 1" write concern,
your transaction can be rolled back if there is a failover..
Atomicity¶
When a transaction commits, all data changes made in the transaction are saved and visible outside the transaction.