Query.prototype.w()
Parameters
- val «String|number» 0 for fire-and-forget, 1 for acknowledged by one server, ‘majority’ for majority of the replica set, or any of the more advanced options.
Returns:
- «Query» this
Sets the specified number of mongod
servers, or tag set of mongod
servers, that must acknowledge this write before this write is considered successful.
This option is only valid for operations that write to the database
deleteOne()
deleteMany()
findOneAndDelete()
findOneAndReplace()
findOneAndUpdate()
remove()
update()
updateOne()
updateMany()
Defaults to the schema’s writeConcern.w
option
Example:
// The 'majority' option means the `deleteOne()` promise won't resolve
// until the `deleteOne()` has propagated to the majority of the replica set
await mongoose.model('Person').
deleteOne({ name: 'Ned Stark' }).
w('majority');
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .