user9131333
user9131333

Reputation:

Mongo Shell doesn't return all matching documents with the find() query

When I run this query, the mongo shell doesn't return all the documents that are in the database collection:

db.collection.find().pretty()

Only a fraction of the actual content is shown. When I head over to the MongoDB Compass GUI, the data is there.

Upvotes: 1

Views: 1337

Answers (2)

DBQuery.shellBatchSize = [maxnumber you need]
DBQuery.shellBatchSize = 300

Upvotes: 0

Jiří Pospíšil
Jiří Pospíšil

Reputation: 14412

Notice that at the very end of the output there's the following line:

Type "it" for more

As suggested, typing "it" and hitting enter fetches more records from the query. Repeat until it says "no cursor". See also Change the mongo Shell Batch Size.

Upvotes: 2

Related Questions