M101J: MongoDB for Java Developers : Homework and Answers
Class started Oct 12, 2015
Homework 1.1
Steps to find answers:-
- Start mongo service using "mongod" command
- go to path homework_1_1/hw1-1 and run "mongorestore". You will see messages like
finished restoring m101.hw1 (1 document)
finished restoring m101.funnynumbers (100 documents)
done
- Now run "mongo" and then run these commands one by one
use m101
db.hw1.findOne()
In answer you will get
{
"_id" : ObjectId("50773061bf44c220307d8514"),
"answer" : 42,
"question" : "The Ultimate Question of Life, The Universe and Everything"
}
Answer : 42
Homework 1.2
Answers are :-
{ "a" : 1, "b" : { "b" : 1, "c" : "foo", "d" : "bar", "e" : [1, 2, 4] } }
{}
{ "title" : "Star Wars", "quotes" : [ "Use the Force", "These are not the droids you are looking for" ], "director" : "George Lucas" }
Homework 1.3
- Install and set up maven according to the mongo university video tutorial.
- Run command mvn compile exec:java -Dexec.mainClass=com.mongodb.SparkHomework
You will have output like
== Spark has ignited ...
>> Listening on 0.0.0.0:4567
167 [Thread-1] INFO org.eclipse.jetty.server.Server - jetty-9.0.2.v20130417
263 [Thread-1] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@12d6bb71{HTTP/1.1}{0.0.0.0:4567}
- Now go to address 0.0.0.0:4567 in your browser
You will find the answer
0 Comments
Post a Comment