Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d5aae5

Browse files
committed
Update links & comments in transactions.js
1 parent dd42534 commit 3d5aae5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎transaction.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const { MongoClient } = require('mongodb');
22

3-
// CRUD operations in transactions must be on existing collections, so be sure you have run
4-
// usersCollection.js prior to running this script.
3+
// In MongoDB 4.2 and earlier, CRUD operations in transactions must be on existing collections
4+
// See https://docs.mongodb.com/manual/core/transactions/#transactions-api for more information
5+
// Be sure you have run usersCollection.js prior to running this script
56

67
async function main() {
78
/**
@@ -64,10 +65,10 @@ async function createReservation(client, userEmail, nameOfListing, reservationDa
6465
const reservation = createReservationDocument(nameOfListing, reservationDates, reservationDetails);
6566

6667
// Step 1: Start a Client Session
67-
// See http://bit.ly/Node_startSession for the startSession() docs
68+
// See https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#startSession for the startSession() docs
6869
const session = client.startSession();
6970

70-
// Step 2: Optional. Define options to use for the transaction
71+
// Step 2: Optional. Define options for the transaction
7172
const transactionOptions = {
7273
readPreference: 'primary',
7374
readConcern: { level: 'local' },
@@ -77,7 +78,7 @@ async function createReservation(client, userEmail, nameOfListing, reservationDa
7778
try {
7879
// Step 3: Use withTransaction to start a transaction, execute the callback, and commit (or abort on error)
7980
// Note: The callback for withTransaction MUST be async and/or return a Promise.
80-
// See http://bit.ly/Node_withTransaction for the withTransaction() docs
81+
// See https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#withTransaction for the withTransaction() docs
8182
const transactionResults = await session.withTransaction(async () => {
8283

8384
// Important:: You must pass the session to each of the operations

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /