mongosh appdb --eval 'db.users.find().limit(5)'

Category: Databases & SQL

mongosh appdb --eval 'db.users.find().limit(5)'

Query documents from a collection

Connects to appdb and prints the first five documents of users; .limit(5) caps the output. find() returns a cursor, and mongosh prints up to 20 documents interactively. Add .pretty() for formatted output.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.