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';
17
17
$ manager = new MongoDB \Driver \Manager (URI );
18
18
19
19
/* 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
+ );
24
25
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
+ );
29
31
30
32
31
33
/* Do the transaction */
Original file line number Diff line number Diff line change @@ -13,10 +13,11 @@ require_once __DIR__ . "/../utils/basic.inc";
13
13
$ manager = new MongoDB \Driver \Manager (URI );
14
14
15
15
/* 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
+ );
20
21
21
22
/* Insert Data */
22
23
$ bw = new \MongoDB \Driver \BulkWrite ();
You can’t perform that action at this time.
0 commit comments