What is MongoDB NoSQL Database?What are its Advantages and Disadvantages?

How MongoDB Works?

{ "name" : "Dustin", "age" 19, "city": "New York", "country" : "USA" }
{ "name" : "Dustin", "age" 19, "city": "New York", "country" : "USA" } { "name" : "Lucas", "age" 20, "city": "Texas", "country" : "USA" } { "name" : "Mike", "age" 18, "city": "Chicago", "country" : "USA" }

MongoDB CRUD Operations

db.collection-name.insertOne( { key1 : value1, key2 : value2, }
db.collection-name.insertMany( [{ key1 : value1, key2 : value2, }, { key1 : value1, key2 : value2, }, { key1 : value1, key2 : value2, }])
db.collection-name.find()
db.collection-name.find({"key" : "value"}, {"key1" : 1, "key2" : 0})
db.collection-name.find({"key" : "value"}, {"key1" : 1, "key2" : 0}).pretty(()
db.collection-name.updateOne({"key" : "value"}, { $set : { "key1" : "value"}})
db.collection-name.updateOne({"key" : "value"}, { $set : { "key1" : "value"}}, {upsert : true})
db.collection-name.deleteOne({"key" : "value"})
db.collection-name.deleteMany({"key" : "value"})

Example of MongoDB Operations

> use demoDB switched to db demoDB >
> use demoDB switched to db demoDB > show collections >
> db.createCollection("demoCollection") { "ok" : 1 } >
> db.demoCollection.insertOne({"name":"Dustin","age":19,"city":"New york"}) { "acknowledged" : true, "insertedId" : ObjectId("5d3b3d607d9aaf21ac74a3e4") } >
> db.demoCollection.find().pretty() { "_id" : ObjectId("5d3b3d607d9aaf21ac74a3e4"), "name" : "Dustin", "age" : 19, "city" : "New york" } >
> db.demoCollection.updateOne({"name":"Dustin"}, {$set : {"age":29}}) { "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 } >
> db.demoCollection.find().pretty() { "_id" : ObjectId("5d3b3d607d9aaf21ac74a3e4"), "name" : "Dustin", "age" : 29, "city" : "New york" } >
> db.demoCollection.deleteOne({"name":"Dustin"}) {"acknowledged" : true, "deletedCount" : 1 } > db.demoCollection.find().pretty() >
> db.demoCollection.drop() true >
> show collections >

Important Terms in MongoDB

Advantages and Disadvantages of MongoDB

Advantages of MongoDB

Disadvantages of MongoDB

MongoDB vs RDBMS

--

--

--

Acodez is one of the leading digital marketing agency in India. We are also a renowned web design and web development company. Visit: https://acodez.in/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why Are You on Indie Hackers Talking About Courses?

Revision 6.4: DASH File Format Specification and File Intercommunication Architecture.

Merging the Enemy functionality

How Custom Software Makes Businesses More Competitive

Week04 — News, Updates & Reminders — AWS | HashiCorp | Istio | Linux

AWS, HashiCorp, Istio and Linux news

My Experience at LetsGrowMore’s Virtual Internship [Dec-2021]

Custom object class array initilization within Simulink Matlab Function Block

Pythons Mutable & Immutable Objects

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Acodez IT Solutions

Acodez IT Solutions

Acodez is one of the leading digital marketing agency in India. We are also a renowned web design and web development company. Visit: https://acodez.in/

More from Medium

How to use AWS Amplify Authentication with Android a-z guide using kotlin coroutines.

Introduction of NodeJS, KoaJS, and Restful services

Using the Redis TimeSeries Database with Java

Developing REST WebService using JAX-RS and Apache Tomcat (TomEE)