MongoDB Get Started

Install MongoDB in Mac OS X

In my opinion, homebrew is easy

brew install mongodb

Check install version

mongod --version

Start mondod server

If you make /data/db directory as data, you can use simple command
Missing this, fails.

mongod

If you want to make your own data directory, use following

mongod -dbpath .

. is current directory

Shutdown mongo server

Use mongo shell

mongo

After accessing, you can use Mongo Shell command

use admin
db.shutdownServer()

db is database object.
MongoDB database object is “db” This object has everything about database.

collection

collection is data set? data itself in MongoDB.
All data(table) is managed by collection.
In db object, collection is manipulated by property.

db.mydata    # mydata is collection of MongoDB

Save

db.collection.save(json) collection is property, json is json style data.
Data style is json.
Example

db.mydata.save({name:'taeyeon', mail:'taeyeon@snsd.com', memo:'She is singer'})

Remove(Delete)

Delete

db.mydata.remove({})

Find

db.mydata.find()   // Find all
db.mydata.find({name:/tae/})