문서 메뉴

문서 홈애플리케이션 개발MongoDB 매뉴얼

cursor.comment()

이 페이지의 내용

  • 정의
  • 행동
  • 예제
  • 출력 예시
cursor.comment()

중요

Mongo쉬 방법

이는 mongosh 메서드입니다. 이는 Node.js 또는 기타 프로그래밍 언어별 드라이버 메서드에 대한 설명서가 아닙니다 .

대부분의 경우 mongosh 메서드는 레거시 mongo 셸 메서드와 동일한 방식으로 작동합니다. 그러나 일부 레거시 메서드는 mongosh 에서 사용할 수 없습니다.

레거시 mongo 셸 문서는 해당 MongoDB 서버 릴리스 문서를 참조하세요.

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

버전 3.2에 새로 추가되었습니다.

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

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

cursor.comment( <string> )

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

매개변수
유형
설명
comment
문자열
쿼리에 적용할 댓글입니다.

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
}
← cursor.collation()

이 페이지의 내용