Playing around with MongoDB – Part 1: setup

This is just a pointer blog to the mongoDB documentation and a basic guide to getting started with using MongoDB on the local system and playing around with it.

Lets first install MongoDB on the Mac and then make a sample app using it.

1.) Installation :
We can use brew to install mongoDB on the mac. Installation instructions can be found here.

Anirudhs-MacBook-Pro:~ anirudh$ brew install mongodb

By default mongodb uses the folder /data/db for the database, so make sure that the directory exists and has all the permissions required.

Once db folder is set, we can run mongodb by the command :

Anirudhs-MacBook-Pro:~ anirudh$ mongod

This will start the mongodb server listening at port 27017.

Once the server is up, we can open a mongo shell to perform the db operations just like using a mysql client.

Login to mongo shell

Anirudhs-MacBook-Pro:~ anirudh$ mongo
MongoDB shell version: 2.6.3
connecting to: test
Welcome to the MongoDB shell.

We can use the help command to see all the operations like create databases, indexes, insert rows, etc.

Lets see few basic examples which can be helpful for our stint with mongo:

To display the database we are using:

 db

To use the database

use <database>

To view all the collections in the db

db.getCollectionNames()

To find

db.collection.find()

More details of getting started are well documented at the mongodb site here.

In the next blog we will make a spring application talk to mongo DB.

Using verbs apart from HTTP verbs(PUT/POST..) in REST URL

As per REST, the URLs should make use of HTTP verbs to expose their REST based services via HTTP. (i.e GET/PUT/POST/DELETE)

So, a resource would be something like

GET ../foods/1 would get you the food with id 1.
PUT ../foods/2 would update the food with id 2.
POST ../foods will add a new food.
DELETE ../foods/1 will delete the food resource with id 1.</span>

But in a real life complex application, we are faced with exposing many services such as approve, reject where it becomes inevitable to add verbs to the URL. What should we do? Should we just have the URLs like ../foods/1/approve ?

What would go wrong if we use verbs in REST URL.
Whether there is some rationale behind it or it just REST dogma..
Apparently, there is :
Read More »

Using Map Reduce to find the twitter trends

Few weeks back while preparing for our presentation for agileNCR 2013, Sanchit and I started working on an interesting problem statement to solve using MapReduce.

We thought of applying MapReduce algorithm to find the trends in Twitter.

A Tweet in a twitter can have hashTags (#helloTwitter) and a certain hashTag used most number of times in tweets globally is said to have highest trend. More details can be found here.

This data is huge and also keeps on increasing, so processing it in traditional manner would not be possible.

Hence we would require hadoop to help us solve this problem.

Twiiter uses Cassandra to store the data in key-value format. Lets assume for simplicity that the key value pair for tweet data looks something like this < twitterHandle,Tweet >.

Read More »

Why would Agile fail for you?

This is not yet-another-agile-gaga blog, but a story, some of you might find it interesting as well.

Not A very long time ago and not in a galaxy far,far away, there were two teams.
One team was following Scrum without Agile Mindset and second had an agile mindset.
The ‘A’ team who were following Scrum, failed!! And ended up blaming agile, whereas the second team ‘B’, came out in flying colors and eventually moved to scrum.

Let’s delve into the details to see what exactly happened…
Read More »