MongoDB is a leading NoSQL database that offers a flexible document-based data model. It provides scalability, high performance, and ease of use for building modern, data-intensive applications in various industries.
Let's take a few minutes to learn how to work with the blazing fast mongodb.
Notes
- You don't need to install everything on dev machine anymore, just launch a docker container and you have the software/services ready for working. BTW, almost everything is "containerized" now, you should leverage it.
- Learn the essential terminologies and try to answer basic questions (like what is docker, which problem does it solve, what is mongodb, collection, document ...)
- When you've got the basics, Google will be your friend (with proper English).
Launch mongodb container
- Follow this link to launch mongodb container.
# Basically this command
docker run --name mongo -d mongodb/mongodb-community-server:latest
Import sample Netflix titles data to netflixdb
Download Netflix sample data (csv, click on 'raw') from this link
Copy the csv file to /tmp folder in mongodb container (replace 8899d85c84b0 with mongodb container ID on your machine)
# List running containers, copy mongodb container ID (something like 8899d85c84b0) for later use
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8899d85c84b0 mongodb/mongodb-community-server:latest "python3 /usr/local/โฆ" 17 hours ago Up 17 hours 27017/tcp mongo
# Copy netflix.csv to container
> docker container cp netflix.csv 8899d85c84b0:/tmp
- Connect to the Mongodb container Bash shell (mongosh):
# Connect to mongodb shell in the container
> docker exec -it mongo bash
# Check if the netflix.csv file is in /tmp folder
> ls /tmp
- Import Netflix sample data to netflixdb with command:
> mongoimport -d netflixdb --collection=title --type=csv --file=/tmp/netflix.csv --headerline
- Check imported documents
# Open mongo shell
> mongosh
# Take a look at first 5 documents
db.title.find().limit(5)
# Press Ctrl-D to exit from mongo shell
# Press Ctrl-D again to exit from Bash shell
More tutorial on basic Mongodb commands
- Continue learning other Mongodb basic commands here
Finally, keep expanding your MongoDB skills by discovering MongoDB documents and try answering the questions below:
- Why is MongoDB high performance?
- How fast are MongoDB queries?
- How can I make MongoDB faster?
- How much RAM does MongoDB need?
- Is MongoDB good for large data?
Top comments (0)