Introduction to MongoDB and Basics Command

 show dbs = is use to show the all database present in Database.

use shubhamdb = if already present then this will switched to shubhamdb database otherwise this will make a new Database name shubhamdb.

Now Need to add some collections (SQL in Tables) in this mongoDb Database. so we use below command.

To create a new database, issue the use <db> command with the database that you would like to create. For example, the following commands create both the database myNewDatabase and the collection myCollection using the insertOne() operation:

use myNewDatabase
db.myCollection.insertOne( { x: 1 } );

If a collection does not exist, MongoDB creates the collection when you first store data for that collection.

myCollection is Collection name (in SQL table Name) insertOne() to inset the collection

BSON stands for Binary Javascript Object Notation. It is a binary-encoded serialization of JSON documents. BSON has been extended to add some optional non-JSON-native data types, like dates and binary data.

show collections : this will show the collection inside the database.
db.collectionName.find()  = this will show data inside the collection name.

db.studentData.insertOne({ name: "Abhinav Singh", age: 25, branch: "Computer Science", isActive: true})


MongoDb generate automatically a unique ID for a collection data.



find() will show the items of particular collections

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form