MongoDB Getting started with MongoDB Hello World

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

After installation process, the following lines should be entered in mongo shell (client terminal).

> db.world.insert({ "speech" : "Hello World!" });
> cur = db.world.find();x=cur.next();print(x["speech"]);

Hello World!

Explanation:

  • In the first line, we have inserted a { key : value } paired document in the default database test and in the collection named world.
  • In the second line we retrieve the data we have just inserted. The retrieved data is kept in a javascript variable named cur. Then by the next() function, we retrieved the first and only document and kept it in another js variable named x. Then printed the value of the document providing the key.


Got any MongoDB Question?