My Blog List

Sunday, September 14, 2014

MongoDB Basic command

I studied mongoDB 
and This mongoDB structure is like json structure
and this has collection.
this is just start time ~ I don't know how deeply i shoud study this mongoDB
but I'm just curious about using it and be interested in getting information of this database

blow post is what i got from O'Reilly - MongoDB- The Definition Guide

34/216page


./mongodb


switch database 
> use footer

show which db i use
> db

CRUD
create, read, update, delete


javascript functions are available in mongoDB


make post data
> post = {"title":"good", 
... "content":"this is body",
... "date" : new Date()}
{
"title" : "good",
"content" : "this is body",
"date" : ISODate("2014-09-15T00:18:45.482Z")
}

and 

i gonna insert this post to blog

>db.blog.insert(post)


find 
> db.blog.find() or db.blog.findOne()


update
> post.comments = []

> db.blog.update({title:"good"}, post)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

delete
> db.blog.remove({title:"good"})


show dbs = show databasenames
show collections = show collections in current database
show users = show users in current database
use <db name> = set current database to <db name>
db.help()
dob.foo.help()


No comments:

Post a Comment