What’s new in MongoDB Shell 2.2.2

I really suffered while using MongoDB Shell because auto completing was not there. I was very hard to type collection and database names correctly. I wished IntelliSense to get into there. I’m tough Microsoft User. Because of that I love IntelliSense a lot. 😉

And there was no any other solution to me to make done MongoDB things easier.  Because available MongoDB GUI’s are not that much good. I feel I’m in 90’s when I’m using them. So after a month I got addicted to Shells. Not Only to mongo shell I practiced PowerShell also.

Image

Now what I wished is arrived in a different form. It’s auto completing. And it made me comfortable because feeling is same like using PowerShell. And also It suggest possible commands and functions. Isn’t it awesome? It makes easier to learn MongoDB. Somehow now MongoDB is having visual differences!

Go Mongo!!!

Advertisements

MongoShell Database Navigation

If you are new to MongoDB you may need to discover the databases and collections (basically objects) on your MongoDB instance. For this easily you can use a GUI tool like MongoVUE. But in this blog post I’m not going to describe about GUI tools. I’m going to explain about MongoShell to navigate through database objects.

I can remember the first day that I used Linux. In that day I fed up with Terminal and gave it up. But now I think its cool!. Smile Some how if you want to do some thing easier I still recommend GUI Tools Winking smile.

First to execute those commands you should log into MongoShell. In windows mongo.exe.

How to take database List?

> show dbs

How to check the database that you are currently using?

> db

or

> print ( db );

How to change to a new database?

> use <database name>

E.g:-

> use AdventureWorks2012 

Winking smile

How to take the list of Collection in current Database?

> show collections

or

> db.getCollectionNames();

How to take the list of Users in Database?

> show users

or

> db.system.users.find();

I want nice output from Mongo Shell

If you have so many documents in your collection in MongoDB database. Sometimes you may want to retrieve few documents. But if we run find() we cant have nice output. You may need to have nice indentation and line breaks. You may want results in more readable way. Then you can use pretty().

image

Who can read this??

image

If you use pretty() you can take nice output with Mongo Shell.