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

$listLocalSessions (집계 단계)

$listLocalSessions

mongod 또는 mongos 인스턴스가 메모리에 캐시한 세션을 나열합니다.

중요

When a user creates a session on a mongod or mongos instance, the record of the session initially exists only in-memory on the instance; i.e. the record is local to the instance. Periodically, the instance will sync its cached sessions to the system.sessions collection in the config database, at which time, they are visible to $listSessions and all members of the deployment. Until the session record exists in the system.sessions collection, you can only list the session via the $listLocalSessions operation.

The $listLocalSessions operation uses the db.aggregate() method and not the db.collection.aggregate().

To run $listLocalSessions, it must be the first stage in the pipeline.

이 단계에는 다음 구문이 있습니다.

{ $listLocalSessions: <document> }

The $listLocalSessions stage takes a document with one of the following contents:

필드
설명

{ }

액세스 제어와 함께 실행하는 경우 현재 인증된 사용자에 대한 모든 세션을 반환합니다.

액세스 제어 없이 실행하는 경우 모든 세션을 반환합니다.

{ users: [ { user: <user>, db: <db> }, ... ] }

지정된 사용자에 대한 모든 세션을 반환합니다. 액세스 제어와 함께 실행하는 경우 인증된 사용자는 cluster에서 listSessions 조치가 있는 권한이 있어야 다른 사용자의 세션을 나열할 수 있습니다.

{ allUsers: true }

모든 사용자에 대한 모든 세션을 반환합니다. 액세스 제어와 함께 실행하는 경우 인증된 사용자는 클러스터에서 listSessions 작업이 있는 권한이 있어야 합니다.

$listLocalSessions 은(는) 거래에서 허용되지 않습니다.

연결된 mongod / mongos 인스턴스의 세션 내 메모리 내 캐시에서 다음 애그리게이션 작업은 모든 세션을 나열합니다.

참고

액세스 제어를 사용하여 실행하는 경우 현재 사용자는 cluster에 대해 listSessions 조치가 있는 권한이 있어야 합니다.

db.aggregate( [ { $listLocalSessions: { allUsers: true } } ] )

연결된 mongod 또는 mongos 인스턴스의 인메모리 캐시 에서 다음 집계 작업은 지정된 사용자 myAppReader@test에 대한 모든 세션을 나열합니다.

참고

액세스 제어와 함께 실행 중이고 현재 사용자가 지정된 사용자가 아닌 경우 현재 사용자에게 cluster에 대한 listSessions 조치가 있는 권한이 있어야 합니다.

db.aggregate( [ { $listLocalSessions: { users: [ { user: "myAppReader", db: "test" } ] } } ] )

다음 애그리게이션 작업을 액세스 제어와 함께 실행 mongod 하면 연결된 / 인스턴스의 인메모리 캐시에서 현재 사용자에 대한 모든 세션이 나열됩니다. mongos

db.aggregate( [ { $listLocalSessions: { } } ] )

액세스 제어 없이 실행하면 작업이 모든 로컬 세션을 나열합니다.

$listLocalSessions 메모리에 캐시된 세션당 하나의 문서가 있는 커서를 반환합니다. 각 문서에는 다음 프로토타입이 있습니다.

{
_id: {
id: <UUID>,
uid: <BinData>
},
lastUse: <date>
}
필드
유형
설명

_id.id

UUID

세션의 전 세계적으로 고유한 식별자(UUID)입니다.

_id.uid

BinData

세션과 연결된 인증된 사용자 자격 자격 증명 의 해시입니다.

lastUse

날짜

세션이 마지막으로 사용된 날짜 및 시간입니다.

이 페이지 평가하기

이 페이지의 내용