Sunday, January 25, 2015

M101JS: MongoDB for Node.js Developers Homework 2.2

Step 1:
you need to download mongoproc

Step 2:
you need to find  a document with highest recorded temperature for each state and adds a "month_high" field for that document and set its value as true.

Solution:
well i did manually and haven't write a  program

you need to find highest recorded temperature for each state.

so first get distinct of each state, using
>db.data.distinct('State');

then using
> db.data.find({ State: "Vermont"}).sort({ Temperature : -1}).limit(1)

get the _id assoicated with it and plly with update query

> db.data.update({ "_id" : ObjectId("54c48c740831934d31102f02") }, { $set : { "month_high" : true }});


do this for all state and then

on mongoproc test your result if it sucess then submit your answer





No comments:

Post a Comment