Skip to content

Commit

Permalink
Update mongo cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Feb 4, 2021
1 parent 756dc97 commit a6dde6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 7 additions & 0 deletions resources/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ Name | Comments
[Kubernetes Deployment Tutorial](https://devopscube.com/kubernetes-deployment-tutorial) |
[Katacoda](https://www.katacoda.com/courses/kubernetes) | Learn Kubernetes using Interactive Browser-Based Scenarios


## Kubernetes Deep Dive

Name | Comments
:------ |:--------:
[Kubernetes Networking](https://github.com/nleiva/kubernetes-networking-links) | Kubernetes Networking Resources
[Liveness and Readiness Probes](https://www.openshift.com/blog/liveness-and-readiness-probes) |

## Kubernetes Deep Dive

Name | Comments
:------ |:--------:
[Kubernetes Troubleshooting Visual Guide](https://learnk8s.io/troubleshooting-deployments?fbclid=IwAR2k6ziNfhBe--CKoYP6qh5_lHYM7_kruDjc1EcyrpgyV_tKJzQlwiuA_Jk) |

## Misc

Name | Comments
Expand Down
18 changes: 7 additions & 11 deletions resources/mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ Name | Description

### Mongo Shell

I assume the following for the purpose of the examples:
* DB name: usage_patterns
* Collection name: accounts
#### General

* DB stats: `db.stats()`
* Switch to a DB: `use usage_patterns`

* Switch to a DB: `use DB_NAME`
* show collections: `show collections`
* Count the number of documents in a collection: `db.accounts.count()`
* Remove all the documents from a collection: `db.accounts.remove({})`

* Export Mongo DB into JSON file: `mongoexport --db=usage_patterns --collection=accounts --out=data.json`

* Rename field: ```db.hosts.updateMany( {}, { $rename: { "hosts": "hosts_file" } } )```
* Count the number of documents in a collection: `db.COLLECTION_NAME.count()`
* Remove all the documents from a collection: `db.COLLECTION_NAME.remove({})`
* Export Mongo DB collection to a JSON file: `mongoexport --db=DB_NAME --collection=COLLECTION_NAME --out=data.json`
* Export specific fields from a Mongo DB collection to a JSON file: `mongoexport --db=DB_NAME --fields=FIELD_NAME,FIELD_NAME2 --collection=COLLECTION_NAME --out=data.json`
* Rename field: ```db.hosts.updateMany( {}, { $rename: { "CURRENT_FIELD_NAME": "NEW_FIELD_NAME" } } )```

#### Aggregations

Expand Down

0 comments on commit a6dde6a

Please sign in to comment.