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
21
21
$ changeStream = $ collection ->watch ([], $ options );
22
22
$ changeStream ->rewind ();
23
23
24
- do {
24
+ while ( true ) {
25
25
$ changeStream ->next ();
26
26
27
27
if ($ changeStream ->valid ()) {
28
- $ event = $ changeStream ->current ();
29
- echo toJSON ($ event ), PHP_EOL ;
28
+ continue ;
30
29
}
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
+ }
32
38
// end-change-stream-post-image
Original file line number Diff line number Diff line change @@ -29,12 +29,18 @@ function toJSON(object $document): string
29
29
$ changeStream = $ collection ->watch ($ pipeline );
30
30
$ changeStream ->rewind ();
31
31
32
- do {
32
+ while ( true ) {
33
33
$ changeStream ->next ();
34
34
35
35
if ($ changeStream ->valid ()) {
36
- $ event = $ changeStream ->current ();
37
- echo toJSON ($ event ), PHP_EOL ;
36
+ continue ;
38
37
}
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
+ }
40
46
// end-change-stream-pipeline
Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ function toJSON(object $document): string
28
28
echo toJSON ($ event ), PHP_EOL ;
29
29
}
30
30
} 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
+ }
31
46
// end-open-change-stream
32
47
33
48
// Updates a document that has a "name" value of "Blarney Castle"
Original file line number Diff line number Diff line change 54
54
$ changeStream = $ collection ->watch ();
55
55
$ changeStream ->rewind ();
56
56
57
- do {
57
+ while ( true ) {
58
58
$ changeStream ->next ();
59
59
60
60
if ($ changeStream ->valid ()) {
61
- $ event = $ changeStream ->current ();
62
- echo toJSON ($ event ) . PHP_EOL ;
61
+ continue ;
63
62
}
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
+ }
65
71
// end-change-stream
You can’t perform that action at this time.
0 commit comments