MongoDB Fundamentals
In the MongoDB shell
$ mongo
Start with an Object
place1 = {
name : "10gen HQ",
address : "578 Broadway 7th Floor",
city : "New York",
zip : "10011",
tags : [ "business", "awesome" ]
}
Insert the record
> db.places.insert(place1)
Query for the record
> db.places.findOne({ zip: "10011", tags: "awesome" })
> db.places.find({tags: "business" })
Update the record (atomically)
db.places.update( {name : "10gen HQ"},
{ $push :
{ comments :
{ author : "steve",
date : 6/26/2012,
text : "Office hours are great!"
}
}
}
)
Written by Steve Francia
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mongodb
Authors
dominikgarber
81.15K
sativaware
80.22K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#