MongoDB Tips

Hi Guys, for those who are new to mongo db, well it is a powerful open source Data Base that is based on  the NoSQL concept. The way we access tables and manipulate records is different to the usual ways we follow with other data bases. Listed below are some helpful MongoDB commands


To Select a DB
---------------
use smsc(db name)

To View the Available Collections
----------------------
show collections


To Find A Record
--------------------
db.messages876.find()

Note: Hear messages876 refers to the collection name

To delete a record
---------------------
db.collection.remove({"name" : "new0912"} )
 
ex: apps is a collection name 
db.apps.remove({"name" : "new0912"})

db.sdp_map.remove({"_id" : "APP_000782"})
db.apps.find({ _id : "APP_000778" });

To Update A Record
-------------------------
db.apps.update({_id : "APP_000193"}, { $set : { usage : 1000 } })
                                                                    

Comments