Download MongoDB

Step 1: Add C:\Program Files\MongoDB\Server\3.2\bin to path.
Step 2: create folder C:\data\db. Mongo is storing data in this folder.
Step 3: open command shell 1: type >mongod
this runs mongo db server in interactive mode
Step 4: open command shell 2: tpe >mongo
this runs shell for Mongo Database

JSON Spec:
Data Types: Object, Array, Value, String, Number
BSON Spec:
Data Types: JSON + Date, Binary

Mongo stores JSON objects in BSON format, inside system.


> show dbs
local 0.000GB
> help help on db methods help on collection methods sharding helpers replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce

show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, ‘global’ is default
use set current database list objects in collection foo { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
> show collections
> show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries

Objects are stored in collections.
Collections are stored in dbs
use video;
db.movies.insertOne({ “title”: “Jaws”, “year”: 1975, “imdb”: “tt0073195” });
db.movies.insertOne({ “title”: “Mad Max 2: The Road Warrior”, “year”: 1981, “imdb”: “tt0082694” })
db.movies.insertOne({ “title”: “Raiders of the Lost Ark”, “year”: 1981, “imdb”: “tt0082971” })

> db.movies.find({“year”:1981}).pretty()
“_id” : ObjectId(“58d8888da651a8f6910286ca”),
“title” : “Mad Max 2: The Road Warrior”,
“year” : 1981,
“imdb” : “tt0082694”
“_id” : ObjectId(“58d88890a651a8f6910286cb”),
“title” : “Raiders of the Lost Ark”,
“year” : 1981,
“imdb” : “tt0082971”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s