cursor.showRecordId()
정의
cursor.showRecordId()
중요
Mongo쉬 방법
이는
mongosh
메서드입니다. 이는Node.js
또는 기타 프로그래밍 언어별 드라이버 메서드에 대한 설명서가 아닙니다.
대부분의 경우
mongosh
메서드는 레거시mongo
shell 메서드와 동일한 방식으로 작동합니다. 그러나 일부 레거시 메서드는mongosh
에서 사용할 수 없습니다.레거시
mongo
셸 문서는 해당 MongoDB 서버 릴리스 문서를 참조하세요.MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 문서를 참조하세요.
Appends the
$recordId
field to documents returned by a query.$recordId
is the internal key that uniquely identifies a document in a collection.$recordId
format:'$recordId': Long(<int>) 반환합니다: A modified cursor object that contains the document fields and the appended $recordId
field.
호환성
이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하십시오.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
예시
이 예제에서는 이 pizzas
collection을 사용합니다.
db.pizzas.insertMany( [ { type: "pepperoni", size: "small", price: 4 }, { type: "cheese", size: "medium", price: 7 }, { type: "vegan", size: "large", price: 8 } ] )
The following find()
example uses
showRecordId()
to append the $recordId
to the
pizza
document fields in the output:
db.pizzas.find().showRecordId()
출력 예시:
[ { _id: ObjectId("62ffc70660b33b68e8f30435"), type: 'pepperoni', size: 'small', price: 4, '$recordId': Long("1") }, { _id: ObjectId("62ffc70660b33b68e8f30436"), type: 'cheese', size: 'medium', price: 7, '$recordId': Long("2") }, { _id: ObjectId("62ffc70660b33b68e8f30437"), type: 'vegan', size: 'large', price: 8, '$recordId': Long("3") } ]