
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
316 Views
Take the help of $addToSet in MongoDB to specify a return format. Let us create a collection with documents −> db.demo207.insertOne({"FavouriteTechnology":"Spring Boot"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8e7a03d395bdc21346f1") } > db.demo207.insertOne({"FavouriteTechnology":"MongoDB"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8e8f03d395bdc21346f2") } > db.demo207.insertOne({"FavouriteTechnology":"Groovy"}); { "acknowledged" : ... Read More

AmitDiwan
331 Views
To determine if a specific value does not exist, use $ne in MongoDB. Let us create a collection with documents −> db.demo206.insertOne( ... { ... "ClientDetails": ... [ ... { ... "Name":"Chris", ... ... Read More

AmitDiwan
617 Views
To count records on the basis of matching criteria, use count(). Let us create a collection with documents −> db.demo205.insertOne( ... { ... ... "id": "101", ... "Name": "", ... "Age": "", ... "isActive": false ... } ...); { ... Read More

AmitDiwan
310 Views
To display only an element found in an array, use aggregate(). Let us create a collection with documents −> db.demo204.insertOne( ... { ... "_id" : 101, ... "Name" : "Chris", ... "Age" : 23, ... "details" : [ ... ... Read More

AmitDiwan
728 Views
To query nested array, use $elemMatch in MongoDB. Let us create a collection with documents −> db.demo203.insertOne({ ... "_id" : "101", ... "Name" : "Chris", ... "details1" : [ ... { ... "empName" : "David", ... "salary" ... Read More

AmitDiwan
365 Views
For information on query plan, use explain() in MongoDB. Let us create a collection with documents −> db.demo202.insertOne({"StudentFirstName":"Chris", "StudentAge":21}); { "acknowledged" : true, "insertedId" : ObjectId("5e3c3bd103d395bdc21346e8") } > db.demo202.insertOne({"StudentFirstName":"David", "StudentAge":23}); { "acknowledged" : true, "insertedId" : ObjectId("5e3c3bd803d395bdc21346e9") } > db.demo202.insertOne({"StudentFirstName":"Bob", "StudentAge":22}); { "acknowledged" : true, ... Read More

AmitDiwan
250 Views
To update only a specific value, use update() and in that set the new value using $set. Let us create a collection with documents −> db.demo201.insertOne({"ClientName":"Chris Brown", "ClientAge":26}); { "acknowledged" : true, "insertedId" : ObjectId("5e3c39ca03d395bdc21346e5") } > db.demo201.insertOne({"ClientName":"David Miller", "ClientAge":35}); { "acknowledged" : true, "insertedId" : ... Read More

AmitDiwan
455 Views
To filter multiple sub-documents in MongoDB, use aggregate(). Let us create a collection with documents −> db.demo200.insertOne( ... { ... "Id":"101", ... "details1":[ ... { ... "isActive":true, ... "SubjectName":"MySQL" ... ... Read More

AmitDiwan
322 Views
For aggregation in MongoDB, use aggregate(). Let us create a collection with documents −> db.demo199.insertOne( ... { ... "details1":{ ... "details2":{ ... "details3":{ ... "Name":"Chris", ... ... Read More

AmitDiwan
360 Views
For this, use $pull along with update. Let us create a collection with documents −> db.demo198.insertOne({"List":{"Values":[10, 20, 30, 30, 70, 80, 90]}}); { "acknowledged" : true, "insertedId" : ObjectId("5e3c224503d395bdc21346df") } > db.demo198.insertOne({"List":{"Values":[56, 978, 56, 34, 23, 34]}}); { "acknowledged" : true, "insertedId" : ObjectId("5e3c225403d395bdc21346e0") } > ... Read More