Mongodb Homework 2 1 Answer Hidden



 As a reminder, to run your blog you type

mvn compile exec:java -Dexec.mainClass=course.BlogController

Or, use an IDE to run it. To play with the blog you can navigate to the following URLs


You will be proving that it works by running our validation script as follows:


You need to run this in a separate terminal window while your blog is running and while the database is running. It makes connectionsto both to determine if your program works properly. Validate connects to localhost:8082 and expects that mongod is running onlocalhost on port 27017.

Read if you want to run your blog on non-standard port, different host or connected to a mongod on different server.

By popular demand, now takes some optional arguments that you can discover with the -h flag. These arguments will allow you to to make a connection to a web server at different port on a different host and connect to a mongod on a different host. You can also use adatabase name other than blog, a necessity if you are running on the free tier at MongoHW (for eg). I won't go into how these arguments work, as they arepretty self documenting. Note that to run the code to connect to a database outside of localhost (for example to a database at MongoHQ), you willneed to make some global changes.

The python validator requires Python 2.7. The code is not 3.0 compliant.Ok, once you get the blog posts working, will print out a validation code for HW 3.2. Please enter it below, exactly asshown with no spaces.njkfd489hj9fhds8934kf23


You have used 0 of 3 submissions



Courseware (/courses/10gen/M101J/2013_October/courseware) Course Info (/courses/10gen/M101J/2013_October/info)Discussion (/courses/10gen/M101J/2013_October/discussion/forum) Wiki (/courses/10gen/M101J/2013_October/course_wiki)Progress (/courses/10gen/M101J/2013_October/progress)


M101J: MongoDB for Java Developers

Homework: HW 3.1

Download the students.json (/static/m101j-october-2013/handouts/students.432aefc2cf4e.json) file to your computer and import itinto your local Mongo instance with this command:

$ mongoimport -d school -c students < students.json

This dataset holds the same type of data as last week's grade collection, but it's modeled differently. You might want to start byinspecting it in the Mongo shell.Write a program in Java that will remove the lowest homework score for each student. Since there is a single document for eachstudent containing an array of scores, you will need to update the scores array and remove the homework.Hint/spoiler: With the new schema, this problem is a lot harder and that is sort of the point. One way is to find the lowest homework incode and then update the scores array with the low homework pruned. If you are struggling with the Java side of this, look at the ArrayList.remove method, which can remove stuff from a Java ArrayList. Note also that when the value for a particular key is list withinMongoDB, the Java driver returns a BasicDBList, which can you cast to an ArrayList.To confirm you are on the right track, here are some queries to run after you process the data with the correct answer shown:Let us count the number of students we have:

> use school> db.students.count()200

Let's see what Demarcus Audette's record looks like:

>db.students.find({_id:100}).pretty(){"_id" : 100,"name" : "Demarcus Audette","scores" : [{"type" : "exam","score" : 30.61740640636871},{"" ""


Courses (/courses)Help (/help) About (/about)Blog ( (/DASHBOARD)

Categories: 1

0 Replies to “Mongodb Homework 2 1 Answer Hidden”

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *