이 버전의 문서는 보관되어 더 이상 지원되지 않습니다. 5.0 배포서버 업그레이드 하려면 MongoDB 6.0 업그레이드 절차를 참조하세요.
정의
cursor.pretty()중요
Mongo쉬 방법
이는
mongosh메서드입니다. 이는Node.js또는 기타 프로그래밍 언어별 드라이버 메서드에 대한 설명서가 아닙니다 .대부분의 경우
mongosh메서드는 레거시mongoshell 메서드와 동일한 방식으로 작동합니다. 그러나 일부 레거시 메서드는mongosh에서 사용할 수 없습니다.레거시
mongo셸 문서는 해당 MongoDB 서버 릴리스 문서를 참조하세요.MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 문서를 참조하세요.
결과를 읽기 쉬운 형식으로 표시하도록 커서를 구성합니다.
pretty()메서드의 프로토타입 형식은 다음과 같습니다.db.collection.find(<query>).pretty()
행동
pretty() 메서드는 다음과 같습니다.
mongosh의 출력 형식을 변경하지 않습니다.레거시 mongo 셸의 출력 형식을 변경합니다.
예시
다음 문서를 살펴보세요.
db.books.save({ "_id" : ObjectId("54f612b6029b47909a90ce8d"), "title" : "A Tale of Two Cities", "text" : "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness...", "authorship" : "Charles Dickens"})
기본적으로 db.collection.find()은(는) 고밀도 형식으로 데이터를 반환합니다.
db.books.find() { "_id" : ObjectId("54f612b6029b47909a90ce8d"), "title" : "A Tale of Two Cities", "text" : "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness...", "authorship" : "Charles Dickens" }
cursor.pretty()를 사용하면 읽기 쉬운 형식으로 데이터를 반환하도록 커서를 설정할 수 있습니다.
db.books.find().pretty() { "_id" : ObjectId("54f612b6029b47909a90ce8d"), "title" : "A Tale of Two Cities", "text" : "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness...", "authorship" : "Charles Dickens" }