Skip to content

Commit c323af3

Browse files
authored
Update README.md
1 parent 6f7e622 commit c323af3

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,91 @@
11
# MongoLearnPod
22
An education GitPod module intended to teach individuals how to use mongo on any machine.
3+
4+
5+
6+
7+
## Unit Learning Objective
8+
Students should be to:
9+
1. Use Docker Compose to start and stop mongoDB environment
10+
2. Use Docker, Terminal & MongoExpress to teach basic mongoDB concepts
11+
3. Distinguish between the name of a docker image (mongo) and the container name (learn-mongo)
12+
4. Use NPM Scripts to store docker commands
13+
14+
15+
# What did you build
16+
Today we'll be learning how to use Docker Compose to learn MongoDB.
17+
18+
## Unit Learning Objective
19+
Students should be to:
20+
1. Use Docker Compose to start and stop mongoDB environment
21+
2. Use docker exec to access the mongoDB Shell
22+
3. Distinguish between the name of a docker image (mongo) and the container name (learn-mongo)
23+
4. Use NPM Scripts to store docker commands such as docker exec for mongo shell
24+
25+
# About me
26+
Hans McMurdy is an experianced web developer and coding teacher.
27+
28+
## About
29+
This is a brief mongo tutorial in GitPod and originally built for docker and docker compose which you can see [here](https://github.com/HansUXdev/OSS-Books/tree/master/JavaScript-First/00-JavaScript-DataBases/mongo).
30+
31+
## Using Mongo Shell to build a database
32+
Lets go ahead and create a new *collection* and use it.
33+
34+
Type the following into the terminal: `use learnMongo`.
35+
36+
We can then show the database we are using by using the `db` command.
37+
38+
Next we are going to insert some data into our new database.
39+
To do this we'll use the the [insert](https://docs.mongodb.com/manual/tutorial/insert-documents/) command.
40+
41+
42+
```js
43+
db.info.insert(
44+
{
45+
"country": "United States of America",
46+
"state": "Arizona",
47+
"cities": ["Phoenix", "Mesa", "Chandler"]
48+
}
49+
)
50+
```
51+
This will insert a new *document* into the info *collection*.
52+
53+
**Exercise**
54+
Next, you should come up with 2 other states, with atleast two cities in each.
55+
56+
Finally, we will use the [.find()]() method to find the document with a state of Arizona.
57+
58+
```js
59+
db.info.find({state:'Arizona'}).pretty()
60+
```
61+
Note that the [.pretty()]() command just formates the data more properly.
62+
63+
64+
By the end of the exercise your terminal should look something like following but with different examples:
65+
[![](exercise1.png)]()
66+
67+
If we open mongo-express, we should see a new database appeared. We can also use the terminal command `show dbs` to display them in terminal.
68+
69+
[![](mongo-express02.png)]()
70+
[![](mongo-express03.png)]()
71+
[![](mongo-express04.png)]()
72+
73+
74+
## Using NPM Scripts
75+
# Package.json is used to demostrate NPM Scripts for use with docker
76+
Students should be able to:
77+
* Identify the package.json file and the script section
78+
* Modify the package.json file to add the docker command
79+
```
80+
"mongo": "docker exec -it learn-mongo mongo",
81+
```
82+
* Distinguish between the name of the docker image (mongo) and the container name (learn-mongo)
83+
84+
* Demonstrate Mongo Terminal Commands
85+
1. Running with docker compose
86+
- ```docker exec -it learn-mongo mongo```
87+
88+
# Conclusion
89+
## Key learnings
90+
## Tips and advice
91+
## Final thoughts and next steps

0 commit comments

Comments
 (0)