AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

Mongo.startSession() (mongosh 메서드)

Mongo.startSession(<options>)

Starts a session for the connection. mongosh assigns the session ID to commands associated with the session.

중요

Mongo쉬 방법

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

데이터베이스 명령에 대해서는 startSession 명령을 참조하십시오.

MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 설명서를 참조하세요.

세션은 세션을 생성한 MongoClient 객체에만 사용할 수 있습니다. 단일 세션은 동시에 사용할 수 없습니다. 단일 세션을 사용하는 작업은 순차적으로 실행해야 합니다.

The startSession() method can take a document with session options. The options available are:

필드
설명

causalConsistency

Boolean. Enables or disables causal consistency for the session. Mongo.startSession() enables causalConsistency by default. Mutually exclusive with snapshot.

세션을 시작한 후에는 causalConsistency 설정을 수정할 수 없습니다.

Mongo() 연결 객체의 인과적 일관성이 비활성화되었거나 그 반대의 경우에도 세션에서는 인과적 일관성이 활성화되었을 수 있습니다. 연결 객체에 인과적 일관성을 설정하려면 Mongo.setCausalConsistency()를 참조하세요.

readConcern

문서입니다. 읽기 고려를 지정합니다.

세션을 시작한 후 설정을 수정하려면 Session.getOptions().setReadConcern()을 참조하세요.

읽기 설정

문서입니다. 읽기 설정을 지정합니다.

읽기 설정 문서에는 mode 필드와 선택 사항인 tags 필드가 포함되어 있습니다.

{ mode: <string>, tags: <array> }

세션을 시작한 후 설정을 수정하려면 Session.getOptions().setReadPreference()을 참조하세요.

retryWrites

부울입니다. 일시적인 네트워크 오류 발생 시 쓰기를 재시도하는 기능을 활성화하거나 비활성화합니다.

If you start mongosh with the --retryWrites option, retryWrites is enabled by default for Mongo.startSession().

세션을 시작한 후에는 retryWrites 설정을 수정할 수 없습니다.

스냅샷

부울. MongoDB 5.0+ 배포를 위한 세션의 스냅샷 읽기 를 활성화합니다. causalConsistency 와 상호 배타적입니다.

쓰기 고려

문서입니다. 쓰기 고려를 지정합니다.

세션을 시작한 후 설정을 수정하려면 Session.getOptions().setWriteConcern()을 참조하세요.

이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

참고

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

The following starts a session with causal consistency and retryable writes enabled on the Mongo() connection object associated with mongosh's global db variable:

db = db.getMongo().startSession({retryWrites: true, causalConsistency: true}).getDatabase(db.getName());
이 페이지 평가하기

이 페이지의 내용