Skip to content

Commit 470b996

Browse files
author
micah
authored
CXX-2679 simplify options in with_transaction example (#1240)
1 parent 72a2598 commit 470b996

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

examples/mongocxx/with_transaction.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,11 @@ int EXAMPLES_CDECL main() {
6666
// uriString = 'mongodb://mongos0.example.com:27017,mongos1.example.com:27017/'
6767
mongocxx::client client{mongocxx::uri{"mongodb://localhost/?replicaSet=repl0"}};
6868

69+
// Prepare to set majority write explicitly. Note: on Atlas deployments this won't always be
70+
// needed. The suggested Atlas connection string includes majority write concern by default.
6971
write_concern wc_majority{};
7072
wc_majority.acknowledge_level(write_concern::level::k_majority);
7173

72-
read_concern rc_local{};
73-
rc_local.acknowledge_level(read_concern::level::k_local);
74-
75-
read_preference rp_primary{};
76-
rp_primary.mode(read_preference::read_mode::k_primary);
77-
7874
// Prereq: Create collections.
7975

8076
auto foo = client["mydb1"]["foo"];
@@ -107,8 +103,6 @@ int EXAMPLES_CDECL main() {
107103
try {
108104
options::transaction opts;
109105
opts.write_concern(wc_majority);
110-
opts.read_concern(rc_local);
111-
opts.read_preference(rp_primary);
112106

113107
session.with_transaction(callback, opts);
114108
} catch (const mongocxx::exception& e) {

0 commit comments

Comments
 (0)