Mongo.setWriteConcern()
On this page本页内容
Definition定义
Mongo.setWriteConcern()
-
Sets the write concern for the设置Mongo()
connection object.Mongo()
连接对象的写入关注。See the Write Concern for an introduction to write concerns in MongoDB.有关在MongoDB中编写关注的介绍,请参阅写入关注。
Syntax语法
The command takes the following form:该命令采用以下形式:
db.getMongo().setWriteConcern( { w: <value>, j: <boolean>, wtimeout: <number> } )
The fields are:字段为:
w | mongod or mongod instances that must acknowledge a write. mongod 或mongod 实例数。
|
j | j: true |
wtimeout | wtimeout is only applicable when w has a value greater than 1 .w 的值大于1 时,wtimeout 才适用。 |
Example实例
In the following example:在以下示例中:
Two两个mongod
ormongod
instances must acknowledge writes.mongod
或mongod
实例必须确认写入。There is a有1
second timeout to wait for write acknowledgements.1
秒的超时等待写入确认。
db.getMongo().setWriteConcern( { w: 2, wtimeout: 1000 } )
Tip