On this page本页内容
startSession
The startSession
command starts a new logical session for a sequence of operations.startSession
命令为一系列操作启动新的逻辑会话。
startSession
has the following syntax:具有以下语法:
{ startSession: 1 }
To run 要运行startSession
, use the db.runCommand( { <command> } )
method.startSession
,请使用db.runCommand( { <command> } )
方法。
db.runCommand( { startSession: 1 } )
featureCompatibilityVersion
must be 3.6 or greater to use the 必须为3.6或更高才能使用startSession
command.startSession
命令。
If the deployment enforces authentication/authorization, you must be authenticated to run the 如果部署强制执行身份验证/授权,则必须对您进行身份验证才能运行startSession
command. startSession
命令。The user who runs 运行startSession
owns the created session, and only that user can use the session.startSession
的用户拥有创建的会话,只有该用户才能使用该会话。
If the deployment does not enforce authentication/authorization, a created session has no owner and can be used by any user on any connection. 如果部署未强制执行身份验证/授权,则创建的会话没有所有者,任何用户都可以在任何连接上使用该会话。If the user authenticates and creates a session for a deployment that does not enforce authentication/authorization, the user owns the session. 如果用户验证并为未强制验证/授权的部署创建会话,则用户拥有该会话。However, any user on any connection may use the session.但是,任何连接上的任何用户都可以使用会话。
If the deployment transitions to auth without any downtime, any sessions without an owner cannot be used.如果部署在没有停机的情况下过渡到身份验证,则无法使用没有所有者的任何会话。
In addition to the status and operation time of the command, the 除了命令的状态和操作时间外,startSession
returns the following session specific information:startSession
还返回以下特定于会话的信息:
id | Document |
id: { id: <UUID> }
|
timeoutMinutes | number |
|