Mongo.getWriteConcern()
定义
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令采用以下形式:
db.getMongo().getWriteConcern()
This operation returns a document with the following values:
{ w: <value>, wtimeout: <number>, j: <boolean> }
这些字段包括:
字段 | 说明 |
---|---|
| 必须确认写入的
有关详细信息,请参阅写关注(write concern)规范。 |
| 一个布尔值。 |
| 等待确认写关注的毫秒数。 |
例子
To return the current write concern, enter the following:
db.getMongo().getWriteConcern()
When a write concern is specified using
Mongo.setWriteConcern()
, the output of
Mongo.getWriteConcern()
is similar to:
WriteConcern { w: 2, wtimeout: 1000, j: true }
The Mongo.getWriteConcern()
command returns an empty line if no
write concern has been specified.