You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: lib/query.js
+47
Original file line number
Diff line number
Diff line change
@@ -1083,6 +1083,53 @@ Query.prototype.session = function session(v) {
1083
1083
returnthis;
1084
1084
};
1085
1085
1086
+
/**
1087
+
* Sets the 3 write concern parameters for this query:
1088
+
*
1089
+
* - `w`: Sets the specified number of `mongod` servers, or tag set of `mongod` servers, that must acknowledge this write before this write is considered successful.
1090
+
* - `j`: Boolean, set to `true` to request acknowledgement that this operation has been persisted to MongoDB's on-disk journal.
1091
+
* - `wtimeout`: If [`w > 1`](/docs/api.html#query_Query-w), the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout.
1092
+
*
1093
+
* This option is only valid for operations that write to the database:
1094
+
*
1095
+
* - `deleteOne()`
1096
+
* - `deleteMany()`
1097
+
* - `findOneAndDelete()`
1098
+
* - `findOneAndReplace()`
1099
+
* - `findOneAndUpdate()`
1100
+
* - `remove()`
1101
+
* - `update()`
1102
+
* - `updateOne()`
1103
+
* - `updateMany()`
1104
+
*
1105
+
* Defaults to the schema's [`writeConcern` option](/docs/guide.html#writeConcern)
1106
+
*
1107
+
* ####Example:
1108
+
*
1109
+
* // The 'majority' option means the `deleteOne()` promise won't resolve
1110
+
* // until the `deleteOne()` has propagated to the majority of the replica set
1111
+
* await mongoose.model('Person').
1112
+
* deleteOne({ name: 'Ned Stark' }).
1113
+
* writeConcern({ w: 'majority' });
1114
+
*
1115
+
* @method writeConcern
1116
+
* @memberOf Query
1117
+
* @instance
1118
+
* @param {Object} writeConcern the write concern value to set
0 commit comments