Query.prototype.wtimeout()
Parameters
- ms «number» number of milliseconds to wait
Returns:
- «Query» this
If w > 1
, 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.
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.wtimeout
option
Example:
// The `deleteOne()` promise won't resolve until this `deleteOne()` has
// propagated to at least `w = 2` members of the replica set. If it takes
// longer than 1 second, this `deleteOne()` will fail.
await mongoose.model('Person').
deleteOne({ name: 'Ned Stark' }).
w(2).
wtimeout(1000);
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .