Skip to content

Instantly share code, notes, and snippets.

Overview

Here you will find instructions for importing the results dataset for the final week of M001: MongoDB Basics into a locally running MongoDB deployment.

Datasets

This dataset is provided in Amazon S3 in a single zip file (9 KB zipped; 147 KB unzipped). The files were created with the mongodump command. This dataset may be imported into your MongoDB deployment using mongorestore. The database included is as follows.

Overview

Here you will find instructions for importing the datasets for M001: MongoDB Basics into a locally running MongoDB deployment.

Datasets

All datasets are provided in Amazon S3 in a single zip file (243 MB zipped; 1.5 GB unzipped). The files were created with the mongodump command. They may be imported into your MongoDB deployment using mongorestore. Note that these datasets include the indexes necessary to support example queries and labs used in M001. The datasets included are as follows.

@shannonbradshaw
shannonbradshaw / task-add-field-to-document.rst
Last active August 10, 2016 21:57
Add a Field to a Document

Suppose the document below is stored in a collection stories within the database folklore. How would you add a field called year with the value 1913 to this document?

{
    _id : 13,
    author : "John Henry",
    name : "Building a Railroad"
}
@shannonbradshaw
shannonbradshaw / task-combine-data-from-multiple-collections.rst
Last active August 5, 2016 12:46
Task: Combine Data from Multiple Collections

Suppose you have data about books split into two collections. The first collection, called books, contains the following documents.

{
    "isbn": "978-3-16-148410-0",
    "title": "Some cool book",
    "author": "John Doe"
}
{
@shannonbradshaw
shannonbradshaw / task-queried-element-in-array.rst
Last active August 1, 2016 12:19
Task: Queried Element in an Array

Suppose you have a collection called figures containing the following documents.

{
    "_id" : 1
    "shapes" : [
        { "shape": "square", "color": "blue" },
        { "shape": "circle", "color": "red" }
    ]
@shannonbradshaw
shannonbradshaw / task-last-10-items.rst
Last active August 5, 2016 21:34
Task: Last 10 Items

Suppose you have a collection called stories containing documents that resemble the following:

{
    _id : ObjectId("579b8063a2f12bdaf5684505"),
    author : "John Henry",
    name : "Building a Railroad"
}
@shannonbradshaw
shannonbradshaw / task-array-containing-specific-value.rst
Created July 31, 2016 19:43
Task: Array Containing Specific Value

Suppose you have a collection called people containing documents that resemble the following:

{
    name : "Kay",
    favoriteFoods : ["mango", "salmon", "quinoa"]
}

In the mongo shell, how would you query for all people listing "mango" as a favorite food?

@shannonbradshaw
shannonbradshaw / task-m-in-name.rst
Last active July 31, 2016 19:44
Task: Users with "m" in Their Name

Suppose you have a users collection in a database named people. Documents in the users collection resemble the following:

{
    _id: 1,
    name: "Gram Parsons",
    DOB: "1946-11-05"
}
@shannonbradshaw
shannonbradshaw / task-drop-database.rst
Last active July 31, 2016 19:31
Drop Database from the Command Line

Assume you have a MongoDB instance running on the default port. Using bash, powershell, or a similar application, write a statement that will drop a MongoDB database called products_test from the command line.

  1. Configure and launch a three member MongoDB replica set on your local computer.
  2. Connect to the primary from the mongo shell and create a database called catalog, then insert one document as follows.
use catalog
db.products.insertOne({name: "Coffee Mug", price: 4})