mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-03-03 00:54:58 +00:00
Update cheatsheets
This commit is contained in:
26
mongo
Normal file
26
mongo
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, common]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# mongo
|
||||
|
||||
> The legacy MongoDB shell. See `mongosh` for the new shell.
|
||||
> Note: all connection options can be replaced with one string: `mongodb://user@host:port/db_name?authSource=authdb_name`.
|
||||
> More information: <https://docs.mongodb.com/manual/reference/program/mongo>.
|
||||
|
||||
- Connect to a local database on the default port (`mongodb://localhost:27017`):
|
||||
|
||||
`mongo`
|
||||
|
||||
- Connect to a database:
|
||||
|
||||
`mongo --host {{host}} --port {{port}} {{db_name}}`
|
||||
|
||||
- Authenticate using the specified username on the specified database (you will be prompted for a password):
|
||||
|
||||
`mongo --host {{host}} --port {{port}} --username {{username}} --authenticationDatabase {{authdb_name}} {{db_name}}`
|
||||
|
||||
- Evaluate a JavaScript expression on a database:
|
||||
|
||||
`mongo --eval '{{JSON.stringify(db.foo.findOne())}}' {{db_name}}`
|
||||
Reference in New Issue
Block a user