Docs Menu

cursor.comment()

cursor.comment()

중요

Mongo쉬 방법

이 페이지에서는 mongosh 메서드를 설명합니다. 이는 Node.js와 같은 언어별 드라이버에 대한 설명서가 아닙니다.

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

쿼리에 comment 필드를 추가합니다.

cursor.comment() 의 구문은 다음과 같습니다:

cursor.comment( <string> )

comment() 에는 다음과 같은 매개 변수가 있습니다.

Parameter
유형
설명

comment

문자열

쿼리에 적용할 댓글입니다.

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

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

참고

이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하십시오.

comment() 주석 문자열을 찾기 작업과 연결합니다. 이렇게 하면 다음 진단 출력에서 특정 쿼리를 더 쉽게 추적할 수 있습니다.

로그,데이터베이스 mongod 프로파일러 튜토리얼 또는 명령에 대한 db.currentOp() 로그 상세도 구성 을 참조하세요.

다음 작업은 restaurants collection의 쿼리에 댓글을 첨부합니다.

db.restaurants.find(
{ "borough" : "Manhattan" }
).comment( "Find all Manhattan restaurants" )

다음은 system.profile 에서 발췌한 것입니다.

{
"op" : "query",
"ns" : "guidebook.restaurant",
"query" : {
"find" : "restaurant",
"filter" : {
"borough" : "Manhattan"
},
"comment" : "Find all Manhattan restaurants"
},
...
}

다음은 mongod 로그에서 발췌한 내용입니다. 가독성을 위해 형식이 지정되었습니다.

중요

QUERY 의 상세도 수준은 0 보다 커야 합니다. 로그 상세도 수준 구성을참조하세요.

2015-11-23T13:09:16.202-05:00 I COMMAND [conn1]
command guidebook.restaurant command: find {
find: "restaurant",
filter: { "borough" : "Manhattan" },
comment: "Find all Manhattan restaurants"
}
...

현재 mongod 인스턴스에서 다음 작업이 실행 중이라고 가정해 보겠습니다.

db.restaurants.find(
{ "borough" : "Manhattan" }
).comment("Find all Manhattan restaurants")

db.currentOp() 명령을 실행하면 다음이 반환됩니다.

{
"inprog" : [
{
"host" : "198.51.100.1:27017",
"desc" : "conn3",
"connectionId" : 3,
...
"op" : "query",
"ns" : "test.$cmd",
"command" : {
"find" : "restaurants",
"filter" : {
"borough" : "Manhattan"
},
"comment" : "Find all Manhattan restaurants",
"$db" : "test"
},
"numYields" : 0,
...
}
],
"ok" : 1
}