Docs 主页 → 开发应用程序 → MongoDB Manual
connectionStatus
定义
语法
该命令具有以下语法:
db.runCommand( { connectionStatus: 1, showPrivileges: <boolean> } )
命令字段
connectionStatus
支持以下可选字段:
字段 | 类型 | 说明 |
---|---|---|
showPrivileges | 布尔 | 可选。将 默认情况下,此字段为 |
例子
要运行connectionStatus
,请使用db.runCommand()
方法,如下所示:
db.runCommand( { connectionStatus: 1, showPrivileges: true } )
输出
connectionStatus.authinfo.authenticatedUserRoles
一个数组,其中包含授予当前连接的每个角色的文档:
connectionStatus.authinfo.authenticatedUserRoles[n].db
应用
role
的数据库。
connectionStatus.authInfo.authenticatedUserPrivileges
一个数组,其中包含描述授予当前连接的动作的文档,按资源分组。
connectionStatus.authInfo.authenticatedUserPrivileges[n].resource
描述数据库以及适用
connectionStatus.authInfo.authenticatedUserPrivileges[n].actions
的集合(如适用)的文档。