MongoDB Shell

MongoDB have a JavaScript shell that permits association with MongoDB occasion from the summon line.

On the off chance that you need to make a table, you ought to name the table and characterize its section and every segment's information sort.

The shell is valuable for performing authoritative capacities and running occurrences.

How to run the shell

To begin the shell, open summon brief, run it as a chairman then run the mongo executable:

$ mongo 
MongoDB shell version: 2.4.0 Connecting to: test

You should to begin mongoDB before beginning the shell on the grounds that shell naturally endeavor to interface with a MongoDB server on startup.

The shell is a full-highlighted JavaScript translator. It is fit for running Arbitrary JavaScript program.

Let us take a simple mathematical program:

>x= 100
>x/ 5;

You can also use the JavaScript libraries

> "Hello, World!".replace("World", "MongoDB");
Hello, MongoDB!

You can even define and call JavaScript functions

> function factorial (n) {

... if (n <= 1) return 1;

... return n * factorial(n - 1);
... }

> factorial (5);


Note: You can create multiple commands.

On the off chance that the announcement is not finished, the shell permits you to keep composing it on the following line. In the event that you press "Enter" three times in succession, it will cross out the half-framed order and get you back to the > - prompt.