Skip to main contentSkip to footer

Final: Question 3 Solution M101JS: MongoDB for Node.js Developers

Rupak Nepali
Share:
Final: Question 3 Solution M101JS: MongoDB for Node.js Developers

Final: Question 3

In this problem, you will update a document in the Enron dataset to illustrate your mastery of updating documents from the shell.

Please add the email address “mrpotatohead@mongodb.com” to the list of addresses in the “headers. To” array for the document with “headers.Message-ID” of “<8147308.1075851042335.JavaMail.evans@thyme>”

After you have completed that task, please download final3.zip from the Download Handout link and run final3-validate.js to get the validation code and put it in the box below without any extra spaces. The validation script assumes that it is connecting to a simple mongo instance on the standard port on the localhost.

Solution: vOnRg05kwcqyEFSve96R  

How to achieve it?

  • Extract the downloaded handout
  • In the first command prompt, go to the Final3 folder where you will see final3-validate.js and package.json files.
  • Now run “npm install”
  • Now open your mongo shell with mongod in second command prompt and again in third command prompt mongo
  • Run command “show databases” and see whether Enron is there or not if install from final question 2 nor run query “use enron”
  • Run the following query:
    db.messages.update({“headers.Message-ID”:”<8147308.1075851042335.JavaMail.evans@thyme>”}, {$addToSet: {“headers.To”: “mrpotatohead@mongodb.com”}}, {multi: 1})
  • Now run the command “node final3-validate.js”  in first command prompt
  • You will see something like below:

    Welcome to the Final Exam Q3 Checker. My job is to make sure you correctly updated the document
    Final Exam Q3 Validated successfully!
    Your validation code is: vOnRg05kwcqyEFSve96R
  • Thus my answer is “vOnRg05kwcqyEFSve96R”
  • It may differ to yours so please confirm before submitting.

Thanks

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment