mongo*: update pages & add mongosh (#10558)

This commit is contained in:
Lena
2023-08-01 09:21:03 +02:00
committed by GitHub
parent 2be0b2e18d
commit cc5486d66e
3 changed files with 38 additions and 12 deletions

21
pages/common/mongosh.md Normal file
View File

@@ -0,0 +1,21 @@
# mongosh
> A new shell for MongoDB, replacement for `mongo`.
> Note: all connection options can be replaced with one string: `mongodb://user@host:port/db_name?authSource=authdb_name`.
> More information: <https://www.mongodb.com/docs/mongodb-shell>.
- Connect to a local database on the default port (`mongodb://localhost:27017`):
`mongosh`
- Connect to a database:
`mongosh --host {{host}} --port {{port}} {{db_name}}`
- Authenticate using the specified username on the specified database (you will be prompted for a password):
`mongosh --host {{host}} --port {{port}} --username {{username}} --authenticationDatabase {{authdb_name}} {{db_name}}`
- Evaluate a JavaScript expression on a database:
`mongosh --eval '{{JSON.stringify(db.foo.findOne())}}' {{db_name}}`