File tree Expand file tree Collapse file tree 4 files changed +45
-12
lines changed Expand file tree Collapse file tree 4 files changed +45
-12
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,18 @@ function toJSON(object $document): string
2121$ changeStream = $ collection ->watch ([], $ options );
2222$ changeStream ->rewind ();
2323
24- do {
24+ while ( true ) {
2525 $ changeStream ->next ();
2626
2727 if ($ changeStream ->valid ()) {
28- $ event = $ changeStream ->current ();
29- echo toJSON ($ event ), PHP_EOL ;
28+ continue ;
3029 }
31- } while (! $ changeStream ->valid () || $ changeStream ->current ()['operationType ' ] !== 'invalidate ' );
30+
31+ $ event = $ changeStream ->current ();
32+ echo toJSON ($ event ), PHP_EOL ;
33+
34+ if ($ changeStream ->current ()['operationType ' ] === 'invalidate ' ) {
35+ break ;
36+ }
37+ }
3238// end-change-stream-post-image
Original file line number Diff line number Diff line change @@ -29,12 +29,18 @@ function toJSON(object $document): string
2929$ changeStream = $ collection ->watch ($ pipeline );
3030$ changeStream ->rewind ();
3131
32- do {
32+ while ( true ) {
3333 $ changeStream ->next ();
3434
3535 if ($ changeStream ->valid ()) {
36- $ event = $ changeStream ->current ();
37- echo toJSON ($ event ), PHP_EOL ;
36+ continue ;
3837 }
39- } while (! $ changeStream ->valid () || $ changeStream ->current ()['operationType ' ] !== 'invalidate ' );
38+
39+ $ event = $ changeStream ->current ();
40+ echo toJSON ($ event ), PHP_EOL ;
41+
42+ if ($ changeStream ->current ()['operationType ' ] === 'invalidate ' ) {
43+ break ;
44+ }
45+ }
4046// end-change-stream-pipeline
Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ function toJSON(object $document): string
2828 echo toJSON ($ event ), PHP_EOL ;
2929 }
3030} while (! $ changeStream ->valid () || $ changeStream ->current ()['operationType ' ] !== 'invalidate ' );
31+
32+ while (true ) {
33+ $ changeStream ->next ();
34+
35+ if ($ changeStream ->valid ()) {
36+ continue ;
37+ }
38+
39+ $ event = $ changeStream ->current ();
40+ echo toJSON ($ event ), PHP_EOL ;
41+
42+ if ($ changeStream ->current ()['operationType ' ] === 'invalidate ' ) {
43+ break ;
44+ }
45+ }
3146// end-open-change-stream
3247
3348// Updates a document that has a "name" value of "Blarney Castle"
Original file line number Diff line number Diff line change 5454$ changeStream = $ collection ->watch ();
5555$ changeStream ->rewind ();
5656
57- do {
57+ while ( true ) {
5858 $ changeStream ->next ();
5959
6060 if ($ changeStream ->valid ()) {
61- $ event = $ changeStream ->current ();
62- echo toJSON ($ event ) . PHP_EOL ;
61+ continue ;
6362 }
64- } while (! $ changeStream ->valid () || $ changeStream ->current ()['operationType ' ] !== 'invalidate ' );
63+
64+ $ event = $ changeStream ->current ();
65+ echo toJSON ($ event ), PHP_EOL ;
66+
67+ if ($ changeStream ->current ()['operationType ' ] === 'invalidate ' ) {
68+ break ;
69+ }
70+ }
6571// end-change-stream
You can’t perform that action at this time.
0 commit comments