An education GitPod module intended to teach individuals how to use mongo on any machine. Here we are applying the idea of GhostPlate built on GitPod to education instead of Industry at scale ...
See that button?
Click it with your right index finger and wait.
If you use any other finger I will bite it off.
Then follow the directions inside the GitPod. Don't worry its still better than Microsoft documentation...
Students should be to:
- Use Docker Compose to start and stop mongoDB environment
- Use Docker, Terminal & MongoExpress to teach basic mongoDB concepts
- Distinguish between the name of a docker image (mongo) and the container name (learn-mongo)
- Use NPM Scripts to store docker commands
Today we'll be learning how to use Docker Compose to learn MongoDB.
Students should be to:
- Use Docker Compose to start and stop mongoDB environment
- Use docker exec to access the mongoDB Shell
- Distinguish between the name of a docker image (mongo) and the container name (learn-mongo)
- Use NPM Scripts to store docker commands such as docker exec for mongo shell
Hans McMurdy is an experianced web developer and coding teacher.
This is a brief mongo tutorial in GitPod and originally built for docker and docker compose which you can see here.
Type the following into a NEW terminal: mongo
. Because no one in chat wanted to help me run it in headless mode (thanks, support :-) ).
Lets go ahead and create a new collection and use it.
Type the following into the terminal: use mongo
.
We can then show the database we are using by using the db
command.
Next we are going to insert some data into our new database. To do this we'll use the the insert command.
db.info.insert(
{
"country": "United States of America",
"state": "Arizona",
"cities": ["Phoenix", "Mesa", "Chandler"]
}
)
This will insert a new document into the info collection.
Exercise Next, you should come up with 2 other states, with atleast two cities in each.
Finally, we will use the .find() method to find the document with a state of Arizona.
db.info.find({state:'Arizona'}).pretty()
Note that the .pretty() command just formates the data more properly.
By the end of the exercise your terminal should look something like following but with different examples:
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.
Students should be able to:
- Identify the package.json file and the script section
- Modify the package.json file to add the docker command
"mongo": "docker exec -it learn-mongo mongo",
-
Distinguish between the name of the docker image (mongo) and the container name (learn-mongo)
-
Demonstrate Mongo Terminal Commands
- Running with docker compose
docker exec -it learn-mongo mongo