File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,17 @@ $EVENTS_COL = COLLECTION_NAME . '_events';
1717$ manager = new MongoDB \Driver \Manager (URI );
1818
1919/* Create collections as that can't be (automatically) done in a transaction */
20- $ cmd = new \MongoDB \Driver \Command ([
21- 'create ' => $ EMPLOYEES_COL
22- ]);
23- $ manager ->executeCommand (DATABASE_NAME , $ cmd );
20+ $ manager ->executeCommand (
21+ DATABASE_NAME ,
22+ new \MongoDB \Driver \Command ([ 'create ' => $ EMPLOYEES_COL ]),
23+ [ 'writeConcern ' => new \MongoDB \Driver \WriteConcern ( \MongoDB \Driver \WriteConcern::MAJORITY ) ]
24+ );
2425
25- $ cmd = new \MongoDB \Driver \Command ([
26- 'create ' => $ EVENTS_COL
27- ]);
28- $ manager ->executeCommand (DATABASE_NAME , $ cmd );
26+ $ manager ->executeCommand (
27+ DATABASE_NAME ,
28+ new \MongoDB \Driver \Command ([ 'create ' => $ EVENTS_COL ]),
29+ [ 'writeConcern ' => new \MongoDB \Driver \WriteConcern ( \MongoDB \Driver \WriteConcern::MAJORITY ) ]
30+ );
2931
3032
3133/* Do the transaction */
Original file line number Diff line number Diff line change @@ -13,10 +13,11 @@ require_once __DIR__ . "/../utils/basic.inc";
1313$ manager = new MongoDB \Driver \Manager (URI );
1414
1515/* Create collections as that can't be (automatically) done in a transaction */
16- $ cmd = new \MongoDB \Driver \Command ([
17- 'create ' => COLLECTION_NAME ,
18- ]);
19- $ manager ->executeCommand (DATABASE_NAME , $ cmd );
16+ $ manager ->executeCommand (
17+ DATABASE_NAME ,
18+ new \MongoDB \Driver \Command ([ 'create ' => COLLECTION_NAME ]),
19+ [ 'writeConcern ' => new \MongoDB \Driver \WriteConcern ( \MongoDB \Driver \WriteConcern::MAJORITY ) ]
20+ );
2021
2122/* Insert Data */
2223$ bw = new \MongoDB \Driver \BulkWrite ();
You can’t perform that action at this time.
0 commit comments