python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 7, Interview Questions Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
Are mongodb ids unique ?

3 Best Ways to Create MongoDB Database [CREATE]

“How to Create Database in MongoDB”? “How many types to Create Database”?
“How”, “When” and “Types to create database”?

In this section, I am going to describes Create Database in MongoDB. Below version 3.4, does not provide any user interface like SQL Server or Robomongo but MongoDB 3.4 solve this problem with help of Robomongo Management Tool.

As per my understanding, it is a great achievement of MongoDB to provide us Robomongo Management Tool.


[Video URL] - CREATE Database MongoDB Using “Robomongo Tool”!

You can Download Robomongo Management Tool and install MongoDB & Robomongo in your machine and start to create MongoDB database, create MongoDB collections, create MongoDB functions and create MongoDB users.

3 Ways to Create MongoDB Database:-
1.      “Use” of Robomongo Management Tool.
2.      “Use” Command Line.
3.      “Use” ASP.Net C# Code.

Here you can decide to create MongoDb database, collections and users.

Create MongoDB Database Using Robomongo Tool:-
You should go (download URL: https://robomongo.org/) and install user interface. It’s so easy to install and start MongoDB developments.

Examples,


Create MongoDB Database Using Command:-
Create a MongoDB database using command in the following steps,
1.      “Use” the Database
2.      Create collections in the Database
3.      Verify that you got what result you wanted

Examples,
Create MongoDB Database Using ASP.Net C#:-
Create a MongoDB database using ASP.Net C# in the following steps,
1.      “Install Csharp driver” from Nuget for MongoDB.
2.      “Use” the mongo namespaces.
3.      Create the “MongoClient” object.
4.      Get the client “Server name”.
5.      Get the “database name” from server.
6.      Create the User collections in the Database and save it.
7.      Finally, you can verify it.

Examples,

//MongoClient
Public static void Main(string[] args)
{
   MongoClient client = new MongoClient();
   var server = client.GetServer();
   var db = server.GetDatabase("mydb");
   var collection = db.GetCollection<User>("Users");

   User user = new User
   {
     Name = "Anil Singh",
     Site= "code-sample.com"
   };
   collection.Save(user);
 }

//Property class.
public class User
{
   public ObjectId Id { get; set; }
   public string Name { get; set; }
   public string Site { get; set; }
}

Reference links,
·        https://robomongo.org/

I hope you are enjoying with this post! Please share with you friends. Thank you!!

ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions