AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

startSession (データベースコマンド)

startSession

The startSession command starts a new logical session for a sequence of operations.

Tip

In mongosh, this command can also be run through the Mongo.startSession() helper method.

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

このコマンドは、次の環境でホストされている配置で使用できます。

  • 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.

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

このコマンドの構文は、次のとおりです。

db.runCommand(
{
startSession: 1
}
)

To run startSession, use the db.runCommand( { <command> } ) method.

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.

配置で認証/認可が強制されない場合、作成されたセッションには所有者がなく、任意の接続で任意のユーザーが使用できます。 ユーザーが認証を行い、認証/認可を強制しない配置のセッションを作成した場合、セッションはユーザーが所有します。 ただし、あらゆる接続上のどのユーザーもセッションを使用できます。

配置がダウンタイムなしで認証に移行すると、所有者のいないセッションは使用できなくなります。

セッションは、セッションを作成したMongoClientオブジェクトでのみ使用できます。 1 つのセッションを同時に使用することはできません。 1 つのセッションを使用する操作は連続して実行する必要があります。

In addition to the status and operation time of the command, the startSession returns the following session specific information:

フィールド
タイプ
説明

id

ドキュメント

セッションの識別子の 16 バイトの UUID(汎用一意識別子)部分を含むドキュメント。

id: { id: <UUID> }

セッションの識別子は、この UUID と認証されたユーザー認証情報のハッシュを連結したもので構成されています。

timeoutMinutes

数値

クライアントが最後に使用してから、期限切れになる前にセッションがアクティブな状態であった時間(分単位)。 デフォルトでは、セッションの有効期限は 30 分です。 この値を変更するには、 の起動時にlocalLogicalSessionTimeoutMinutes パラメータを設定しますmongodレプリカセットとシャーディングされたクラスターの場合、すべてのノードに同じ 値を指定する必要があります。

このページを評価