MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /
Cursors

cursor.pretty()

cursor.pretty()

重要

mongosh メソッド

これはmongoshメソッドです。 これは、 Node.jsまたはその他のプログラミング言語固有のドライバー メソッドのドキュメントではありません

ほとんどの場合、 mongoshメソッドはレガシーの mongo shell メソッドと同じように動作します。 ただし、一部のレガシー メソッドはmongoshでは利用できません。

レガシーmongo shell のドキュメントについては、対応する MongoDB Server リリースのドキュメントを参照してください。

MongoDB API ドライバーについては、各言語のMongoDB ドライバードキュメント を参照してください。

読みやすい形式で結果を表示するようにカーソルを設定します。

pretty() メソッドのプロトタイプ形式は次のとおりです。

db.collection.find(<query>).pretty()

pretty() メソッドです。

次の文書をご覧ください。

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"
}

戻る

cursor.objsLeftInBatch

項目一覧