Complete the code to start a transaction in MongoDB.
const session = client.startSession();
session.[1]();To begin a transaction, you must call startTransaction() on the session.
Complete the code to commit a transaction in MongoDB.
await session.[1]();To save all changes made in a transaction, use commitTransaction().
Fix the error in aborting a transaction in MongoDB.
await session.[1]();To cancel all changes in a transaction, use abortTransaction().
Fill both blanks to correctly use a transaction with commit and session end.
try { await session.[1](); // perform operations await session.[2](); } finally { await session.endSession(); }
Start the transaction with startTransaction() and commit it with commitTransaction().
Fill all three blanks to abort a transaction and end the session properly.
try { await session.[1](); // perform operations if (error) { await session.[2](); } else { await session.commitTransaction(); } } finally { await session.[3](); }
Start the transaction, abort if error, and always end the session.
