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

커서.isExhausted() (mongosh 메서드)

cursor.isExhausted()

중요

Mongo쉬 방법

This page documents a mongosh method. This is not the documentation for a language-specific driver, such as Node.js.

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

반환합니다:

부울

cursor.isExhausted() returns false if documents remain in the current document batch read by the cursor. Otherwise, returns true.

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

  • 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.

tailable cursor( tailable cursor)와 함께 isExhausted() 을(를) 사용할 수 있습니다. tailable cursor는 현재 배치에 남아 있는 문서가 없더라도 열린 상태로 유지됩니다. 남아 있는 문서가 없으면 다른 커서가 자동으로 닫힙니다.

change stream 에는 isExhausted() 을(를) 사용할 수 없습니다. 대신 다음을 검사합니다:

change stream 예시는 보기 예시 및 change stream 이미지 예시를 참조하세요.

이 섹션에는 커서를 사용하여 기상 센서의 온도 측정값으로 collection에서 문서를 읽는 예가 포함되어 있습니다. isExhausted() 의 예가 표시됩니다.

1

실행:

db.sensor.insertMany( [
{ _id: 0, temperature: 12 },
{ _id: 1, temperature: 23 }
] )
2

sensor collection에서 문서를 읽는 sensorCursor 이라는 커서 변수를 만듭니다.

var sensorCursor = db.sensor.find()
3

실행:

sensorCursor.count()

collection에 두 개의 문서가 있으므로 출력은 2 입니다.

4

실행:

sensorCursor.next()

출력:

{ _id: 0, temperature: 12 }
5

실행:

sensorCursor.isExhausted()

sensorCursor 에 문서가 남아 있으므로 출력은 false 입니다.

6

실행:

sensorCursor.next()

출력:

{ _id: 1, temperature: 23 }
7

실행:

sensorCursor.next()

더 이상 문서가 없으며 이 예시에서는 null 을 반환합니다.

8

실행:

sensorCursor.isExhausted()

더 이상 문서가 없으며 isExhausted() 이 true 을 반환합니다.

이 페이지 평가하기

이 페이지의 내용