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

$listSessions (집계 단계)

$listSessions

config 데이터베이스의 system.sessions collection에 저장된 모든 세션을 나열합니다. 이러한 세션은 MongoDB deployment의 모든 구성원이 볼 수 있습니다.

중요

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.

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

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

{ $listSessions: <document> }

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

필드
설명

{ }

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

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

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

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

{ allUsers: true }

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

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

system.sessions 컬렉션에서 다음 집계 작업은 모든 세션을 나열합니다.

참고

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

use config
db.system.sessions.aggregate( [ { $listSessions: { allUsers: true } } ] )

system.sessions 2} collection에서 다음 집계 연산은 지정된 사용자 myAppReader@test에 대한 모든 세션을 나열합니다:

참고

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

use config
db.system.sessions.aggregate( [ { $listSessions: { users: [ {user: "myAppReader", db: "test" } ] } } ] )

system.sessions collection에서 액세스 제어와 함께 실행하는 경우 다음 집계 연산은 현재 사용자의 모든 세션을 나열합니다.

use config
db.system.sessions.aggregate( [ { $listSessions: { } } ] )

액세스 제어 없이 실행하면 연산은 모든 세션을 나열합니다.

MongoDB Node.js 운전자 사용하여 집계 파이프라인 에 $listSessions 단계를 추가하려면 파이프라인 객체 에서 $listSessions 연산자 사용합니다. system.sessions 컬렉션에서 파이프라인 실행합니다.

다음 집계 작업은 모든 세션을 나열합니다.

const db = client.db("config");
const collection = db.collection("system.sessions");
const pipeline = [{ $listSessions: { allUsers: true } }];
const cursor = collection.aggregate(pipeline);
return cursor;

참고

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

다음 집계 작업은 지정된 사용자 myAppReader@test에 대한 모든 세션을 나열합니다.

const db = client.db("config");
const collection = db.collection("system.sessions");
const pipeline = [
{
$listSessions: {
users: [{ user: "myAppReader", db: "test"}]
}
}
];
const cursor = collection.aggregate(pipeline);
return cursor;

참고

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

액세스 제어와 함께 실행 다음 집계 작업은 현재 사용자의 모든 세션을 나열합니다.

const db = client.db("config");
const collection = db.collection("system.sessions");
const pipeline = [{ $listSessions: {} }];
const cursor = collection.aggregate(pipeline);
return cursor;

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

$listSessions 세션당 하나의 문서가 포함된 커서를 반환합니다. 각 문서에는 다음 프로토타입이 있습니다.

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

_id.id

UUID

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

_id.uid

BinData

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

lastUse

날짜

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

이 페이지 평가하기

이 페이지의 내용