With a bit of intro, lets get to some work with MongoDB.

CRUD in programming terms often refers to, C: Create, R: Read, U: Update, D: Delete Operations. So how do we achieve them?

Create

MongoDB shell version: 1.2.2
url: test
connecting to: test
type "exit" to exit
type "help" for help

> use studDB
switched to db studDB

## Add field
> db.stud.save({id:1,name:'Alice',grade:'A'})

## Other way to add field
> field={id:3,name:'Chetan',grade:'C'}                                            
{ "id" : 3, "name" : "Chetan", "grade" : "C" }

> db.stud.save(field)

Read

## All fields
> db.stud.find().forEach(printjson)
{
    "_id" : ObjectId("4fe18ba92d9041659445d3d0"),
    "id" : 1,
    "name" : "Alice",
    "grade" : "A"
}
{
    "_id" : ObjectId("4fe18d702d9041659445d3d1"),
    "id" : 3,
    "name" : "Chetan",
    "grade" : "C"
}

## First field

> db.stud.findOne()     
{
    "_id" : ObjectId("4fe18ba92d9041659445d3d0"),
    "id" : 1,
    "name" : "Alice",
    "grade" : "A"
}

Update

> db.stud.update({name:"Chetan"}, {$set:{grade:"C+"}})                                                      

> db.stud.find().forEach(printjson)
{
    "_id" : ObjectId("4fe18ba92d9041659445d3d0"),
    "id" : 1,
    "name" : "Alice",
    "grade" : "A"
}
{
    "_id" : ObjectId("4fe18d702d9041659445d3d1"),
    "id" : 3,
    "name" : "Chetan",
    "grade" : "C+"
}

Delete

> db.stud.remove({name:"Chetan"})

> db.stud.find().forEach(printjson)
{
    "_id" : ObjectId("4fe18ba92d9041659445d3d0"),
    "id" : 1,
    "name" : "Alice",
    "grade" : "A"
}