M001: MongoDB Basics Chapter 2: The MongoDB Query Language + Atlas 课后习题答案
Lab 2.0: Create an Atlas Sandbox Cluster (Ungraded)
Please note that, while we’ve labeled this as a lab, it is ungraded. This writeup is here simply to get you started on creating an Atlas cluster.
- Go to https://cloud.mongodb.com/links/registerForAtlas and complete the account creation form you see on that page. Please make sure you see the message “Sign up for MongoDB Atlas” at the top of the page.
Once you have completed the registration form, in the next page that appears, you will be asked to choose a new group name. We use groups to manage access to Atlas clusters. Please use the name, m001-sandbox.
提醒
2018-08-23 15:58:34
在 Atlas 里我们不需要再输入 group name,只需要点击 New Project 创建 project,然后创建 cluster 即可
- Once you have created a group, in the next page, enter the name, Sandbox for your cluster.
- On the same page, select the M0 instance size. Note that the “Pricing” now changes to say “$0.00/forever”. You do NOT need to enter a credit card to create a free-tier Atlas cluster (M0). They are free.
- Scroll to the bottom of the cluster-creation form and enter an administrative username and password. Please enter the username, m001-student and the password, m001-mongodb-basics.
- Once you’ve entered your username and password, click Confirm & Deploy. You will need to wait a few minutes for your cluster to be spun up.
- Once your cluster is ready, click on the Security tab and then on the IP Whitelist tab. Click the ADD IP ADDRESS button and, then, in the modal that pops up, click ALLOW ACCESS FROM ANYWHERE. Click the CONFIRM button and wait while the security settings for your cluster are configured.
Note that we do not generally recommend opening an Atlas cluster to allow access from anywhere. We do that for this class to minimize network issues that you might run into.
Lab 2.1: How Many Comedies?
Problem:
- If you have not already loaded the video.movieDetails collection, please review the lesson “Loading Data into Your Sandbox Cluster” for a tutorial. Then, use the script, loadMovieDetailsDataset.js, provided in the handouts for the lesson, “Connecting to an Atlas Cluster from the Mongo Shell” to load the movieDetails collection.
- Use Compass to connect to your sandbox cluster.
- In Compass, view the video.movieDetails collection and apply the filter { genres: “Comedy”}.
How many documents in video.movieDetails match the filter {
genres: “Comedy”}?
Answer:
detailed answer:
If you have loaded the movieDetails collection, the filter {
genres: “Comedy”} will match 749 documents.