@@ -51,14 +51,15 @@ class Watch implements Executable
51
51
*
52
52
* Supported options:
53
53
*
54
- * * fullDocument (string): Allowed values: ‘default’, ‘updateLookup’.
55
- * Defaults to ‘default’. When set to ‘updateLookup’, the change
56
- * notification for partial updates will include both a delta describing
57
- * the changes to the document, as well as a copy of the entire document
58
- * that was changed from some time after the change occurred. For forward
59
- * compatibility, a driver MUST NOT raise an error when a user provides
60
- * an unknown value. The driver relies on the server to validate this
61
- * option.
54
+ * * fullDocument (string): Determines whether the "fullDocument" field
55
+ * will be populated for update operations. By default, change streams
56
+ * only return the delta of fields during the update operation (via the
57
+ * "updateDescription" field). To additionally return the most current
58
+ * majority-committed version of the updated document, specify
59
+ * "updateLookup" for this option. Defaults to "default".
60
+ *
61
+ * Insert and replace operations always include the "fullDocument" field
62
+ * and delete operations omit the field as the document no longer exists.
62
63
*
63
64
* * resumeAfter (document): Specifies the logical starting point for the
64
65
* new change stream.
@@ -69,7 +70,9 @@ class Watch implements Executable
69
70
* This is not supported for server versions < 3.2 and will result in an
70
71
* exception at execution time if used.
71
72
*
72
- * * readPreference (MongoDB\Driver\ReadPreference): Read preference.
73
+ * * readPreference (MongoDB\Driver\ReadPreference): Read preference. This
74
+ * will be used to select a new server when resuming. Defaults to a
75
+ * "primary" read preference.
73
76
*
74
77
* * maxAwaitTimeMS (integer): The maximum amount of time for the server to
75
78
* wait on new documents to satisfy a change stream query.
@@ -93,6 +96,11 @@ class Watch implements Executable
93
96
*/
94
97
public function __construct (Manager $ manager , $ databaseName , $ collectionName , array $ pipeline , array $ options = [])
95
98
{
99
+ $ options += [
100
+ 'fullDocument ' => self ::FULL_DOCUMENT_DEFAULT ,
101
+ 'readPreference ' => new ReadPreference (ReadPreference::RP_PRIMARY ),
102
+ ];
103
+
96
104
if (isset ($ options ['batchSize ' ]) && ! is_integer ($ options ['batchSize ' ])) {
97
105
throw InvalidArgumentException::invalidType ('"batchSize" option ' , $ options ['batchSize ' ], 'integer ' );
98
106
}
0 commit comments