MongoDB..Show me some query

Hopefully, the MongoDB set up in the last post is still working.
Let’s create a database and name it Awesome(just because we can).

> use Awesome
switched to db Awesome

Now, the database can have collection and those collections will have documents.
So, let’s create a couple of collections and then use show collections to view them.

{ "ok" : 1 }
> show collections

MongoDB is schemaless, which means the schema will be defined by the document structure you throw in there.
So, if you insert nothing (i.e. no fields) it would still be a document with an ObjectID.


{ "_id" : ObjectId("524dc34c1ad09caf6c994f8b") }


{ "_id" : ObjectId("524dc34c1ad09caf6c994f8b") }
{ "_id" : ObjectId("524dc4141ad09caf6c994f8c"), "name" : "awesome", "age" : 1 }

I have mentioned ObjecId and find just now. I will elaborate a bit more in upcoming posts. What you have seen is the JS shell, so insertion, retrieval etc.. is all in Javascript. When we insert we send in JSON and we get back JSON when we are querying for documents.


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