Para agentes de IA: hay un índice de documentación disponible en https://www.mongodb.com/es/docs/llms.txt — versiones en markdown de todas las páginas están disponibles agregando .md a cualquier ruta URL.
Docs Menu

cursor.pretty() (método mongosh)

cursor.pretty()

Importante

Método mongosh

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

Para los drivers de API de MongoDB, consulte la documentación del driver de MongoDB específica del lenguaje.

Configura el cursor para mostrar los resultados en un formato fácil de leer.

The pretty() method has the following prototype form:

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

El pretty() método:

Considera el siguiente documento:

db.books.insertOne({
"_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"})

Por defecto, db.collection.find() devuelve datos en un formato denso:

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

Al usar, puede configurar el cursor para que devuelva los datos en un formato más fácil de cursor.pretty() leer:

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"
}
Califique esta página