Saturday, March 28, 2015
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
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
Saturday, January 24, 2015
M101JS: MongoDB for Node.js Developers - Homework 2.1
M101JS: MongoDB for Node.js Developers - Homework 2.1
Step 1:
Download Homework material
Step 2:
Import Weather Data using
Step 3:
Validate your data using
> use weather
> db.data.find().count();
> 2963
Step 4:
Question:
you need to find the state that recorded the lowest temperature when the wind was coming from the west. (wind direction from 180 to 360). you need to get the name of the state.
Solution:
1) you need to first find the record that has wind direction between 180 to 360.
Query : { "Wind Direction":{$gte:180,$lte:360}}
> db.data.find({ "Wind Direction":{$gte:180,$lte:360}})
now we need to sort to find the lowest temperature, so you need to add sort in ascending order.
so add .sort({ Temperature : 1}) to above query.
so final query will be
> db.data.find({ "Wind Direction" : { $gte : 180, $lte : 360}}).sort({ Temperature : 1})
now in the first row you can look for the state
you will get your answer as
New Mexico
Step 1:
Download Homework material
Step 2:
Import Weather Data using
mongoimport --type csv --headerline weather_data.csv -d weather -c data
Step 3:
Validate your data using
> use weather
> db.data.find().count();
> 2963
Step 4:
Question:
you need to find the state that recorded the lowest temperature when the wind was coming from the west. (wind direction from 180 to 360). you need to get the name of the state.
Solution:
1) you need to first find the record that has wind direction between 180 to 360.
Query : { "Wind Direction":{$gte:180,$lte:360}}
> db.data.find({ "Wind Direction":{$gte:180,$lte:360}})
now we need to sort to find the lowest temperature, so you need to add sort in ascending order.
so add .sort({ Temperature : 1}) to above query.
so final query will be
> db.data.find({ "Wind Direction" : { $gte : 180, $lte : 360}}).sort({ Temperature : 1})
now in the first row you can look for the state
you will get your answer as
New Mexico
M101JS: MongoDB for Node.js Developers - Week 2
hi friends,
i will start with week 2 introduction.
Week 2 of of m101js is related with CRUD operation of mongodb. you will learn following things
i will start with week 2 introduction.
Week 2 of of m101js is related with CRUD operation of mongodb. you will learn following things
- Mongo Shell
- BSON
- Insert Operation
- find
- Field Selection
- various operator like $gt, $lt,regex,$or,$and,$set,$unset
- upserts
- multiupdate
- removing data
- Above Operation with node.js
Friday, January 23, 2015
M101JS: MongoDB for Node.js Developers Homework 1.3
M101JS: MongoDB for Node.js Developers Homework 1.3
Step 1:
Download the homework 1.3 material
Step 2:
Untar or unzip the material
Go to To unzip path
C:\Users\Downloads\hw1-3.607f73fdd4fc\hw1-3
Step 3:
type command> mongorestore dump
Step 4:
on unix:
install driver of node.js for mongodb
for windows:
http://nodejs.org/#download
Now Run The application.
you will get your answers
Hello, Agent 007.
Step 1:
Download the homework 1.3 material
Step 2:
Untar or unzip the material
Go to To unzip path
C:\Users\Downloads\hw1-3.607f73fdd4fc\hw1-3
Step 3:
type command> mongorestore dump
Step 4:
on unix:
install driver of node.js for mongodb
npm install mongodb
for windows:
http://nodejs.org/#download
Now Run The application.
node app.js
you will get your answers
Hello, Agent 007.
M101JS: MongoDB for Node.js Developers - Homework 1.2
M101JS: MongoDB for Node.js Developers - Homework 1.2
Step 1:
Download the homework 1.2 material
Step 2:
Untar or unzip the material
Go to To unzip path
C:\Users\Downloads\hw1-2.92b836706307\hw1-2
Step 3:
type command> mongorestore dump
Step 4:
on unix:
install driver of node.js for mongodb
for windows:
http://nodejs.org/#download
Now Run The application.
you will get your answers
I like kittens
Step 1:
Download the homework 1.2 material
Step 2:
Untar or unzip the material
Go to To unzip path
C:\Users\Downloads\hw1-2.92b836706307\hw1-2
Step 3:
type command> mongorestore dump
Step 4:
on unix:
install driver of node.js for mongodb
npm install mongodb
for windows:
http://nodejs.org/#download
Now Run The application.
node app.js
you will get your answers
I like kittens
M101JS: MongoDB for Node.js Developers - Homework 1.1
M101JS: MongoDB for Node.js Developers
HomeWork 1.1: you need to import handout material using mongo restore- Download the HomeWork Material.
- unzip or untar the above folder
- go to terminal or cmd with unzip path
- type mongorestore dump
- note: dump is folder name
- after running the command you will upload all the bson data into mongo.
Now To validate your answer type in cmd:
> use hw1_1
> db.hw1_1.findone()
>Output:
{
"_id" : ObjectId("51e4524ef3651c651a42331c"),
"answer" : "Hello from MongoDB!"
}
so your first week answer is
Hello from MongoDB!
Subscribe to:
Posts (Atom)