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

db.getCollectionNames() (mongosh 메서드)

db.getCollectionNames()

Returns an array containing the names of all collections and views in the current database, or if running with access control, the names of the collections according to user's privilege. For details, see Required Access.

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

  • 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 db.getCollectionNames() is equivalent to:

db.runCommand(
{
listCollections: 1.0,
authorizedCollections: true,
nameOnly: true
}
)
  • 필수 액세스 권한(데이터베이스에 대해 listCollections 작업을 부여하는 권한)이 있는 사용자의 경우 이 메서드는 데이터베이스에 필요한 모든 컬렉션의 이름을 나열합니다.

  • 필수 액세스 권한이 없는 사용자의 경우, 이 메서드는 사용자에게 권한이 있는 컬렉션만 나열합니다. 그 예로 사용자에게 데이터베이스의 특정 컬렉션에 대한 find이(가) 있다면 이 메서드가 해당 컬렉션만을 반환합니다.

If the client that issued db.getCollectionNames() disconnects before the operation completes, MongoDB marks db.getCollectionNames() for termination using killOp.

복제본 세트 노드에서 실행하는 경우 listCollections 연산을 수행하려면 노드가 PRIMARY 또는 SECONDARY 상태여야 합니다. 노드가 STARTUP2와 같은 다른 상태이면 연산 오류가 발생합니다.

다음은 records 데이터베이스에 있는 모든 컬렉션의 이름을 반환합니다.

use records
db.getCollectionNames()

이 메서드는 배열의 collection 이름을 반환하며 다음과 같습니다.

[ "employees", "products", "mylogs", "system.indexes" ]
이 페이지 평가하기