2016-08-08 08:04:25 +01:00
|
|
|
# mongo
|
|
|
|
|
|
|
|
> MongoDB interactive shell client.
|
2019-06-04 10:25:14 +01:00
|
|
|
> More information: <https://docs.mongodb.com/manual/reference/program/mongo>.
|
2016-08-08 08:04:25 +01:00
|
|
|
|
|
|
|
- Connect to a database:
|
|
|
|
|
|
|
|
`mongo {{database}}`
|
|
|
|
|
|
|
|
- Connect to a database running on a given host on a given port:
|
|
|
|
|
|
|
|
`mongo --host {{host}} --port {{port}} {{database}}`
|
|
|
|
|
|
|
|
- Connect to a database with a given username; user will be prompted for password:
|
|
|
|
|
|
|
|
`mongo --username {{username}} {{database}} --password`
|
|
|
|
|
2021-05-20 21:13:41 +01:00
|
|
|
- Evaluate a JavaScript expression on the database:
|
2016-08-08 08:04:25 +01:00
|
|
|
|
|
|
|
`mongo --eval '{{JSON.stringify(db.foo.findOne())}}' {{database}}`
|