startSession
정의
startSession
The
startSession
command starts a new logical session for a sequence of operations.팁
mongosh
에서 이 명령을Mongo.startSession()
헬퍼 메서드를 통해서도 실행할 수 있습니다.헬퍼 메서드는
mongosh
사용자에게 편리하지만 데이터베이스 명령과 동일한 수준의 정보를 반환하지 못할 수 있습니다. 편의가 필요하지 않거나 추가 리턴 필드가 필요한 경우 데이터베이스 명령을 사용합니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하십시오.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.runCommand( { startSession: 1 } )
startSession
를 실행하려면 db.runCommand( { <command> } )
메서드를 사용합니다.
db.runCommand( { startSession: 1 } )
중요
featureCompatibilityVersion
must be 3.6 or greater to use the
startSession
command.
행동
If the deployment enforces authentication/authorization, you must be
authenticated to run the startSession
command. The user
who runs startSession
owns the created session, and only
that user can use the session.
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.
세션은 세션을 생성한 MongoClient
객체에만 사용할 수 있습니다. 단일 세션은 동시에 사용할 수 없습니다. 단일 세션을 사용하는 작업은 순차적으로 실행해야 합니다.
출력
In addition to the status and operation time of the command, the
startSession
returns the following session specific
information:
필드 | 유형 | 설명 | |
---|---|---|---|
| 문서 | The document that contains the 16-byte Universally Unique Identifier (UUID) portion of the session's identifier.
The session's identifier consists of this UUID concatenated with the hash of the authenticated user credentials. | |
| 숫자 | The amount of time, in minutes, since the last client use that a
session remains active before expiring. By default, sessions
have an expiration timeout of 30 minutes. To change the value,
set the |