- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1659 Articles for Big Data Analytics
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
181 Views
You can use $ne operator for this. Let us first create a collection with documents −> db.searchByPropertyName.insertOne({"FirstName":"Larry", "Age":23}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7af7219729fde21ddb5") } > db.searchByPropertyName.insertOne({"FirstName":null, "Age":21}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7b97219729fde21ddb6") } > db.searchByPropertyName.insertOne({"FirstName":"John", "Age":22}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7c57219729fde21ddb7") } > db.searchByPropertyName.insertOne({"FirstName":null, "Age":25}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7d07219729fde21ddb8") } > db.searchByPropertyName.insertOne({"FirstName":"David", "Age":20}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7df7219729fde21ddb9") }Following is the query to display all documents from the collection with the help of find() prettyprint −> db.searchByPropertyName.find().pretty();This will produce ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
133 Views
You can use $not operator along with $type for this. Let us first create a collection with documents −> db.highestNumericValueOfAColumnDemo.insertOne( ... { ... "StudentName": "John", ... "StudentMathMarks":69 ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5cba05727219729fde21ddb1") } > db.highestNumericValueOfAColumnDemo.insertOne( ... { ... "StudentName": "Carol", ... "StudentMathMarks":"89" ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5cba059d7219729fde21ddb2") } > db.highestNumericValueOfAColumnDemo.insertOne( ... { ... "StudentName": "Chris", ... "StudentMathMarks":82 ... } ... ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
386 Views
To delete a MongoDB field and value, you can use $unset operator. Let us first create a collection with documents −> db.deleteFieldDemo.insertOne({"FirstName":"John", "LastName":"Smith"}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9fb767219729fde21ddad") } > db.deleteFieldDemo.insertOne({"FirstName":"David", "LastName":"Miller"}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9fb837219729fde21ddae") } > db.deleteFieldDemo.insertOne({"FirstName":"Carol", "LastName":"Taylor"}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9fb8d7219729fde21ddaf") }Following is the query to display all documents from the collection with the help of find() method −> db.deleteFieldDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cb9fb767219729fde21ddad"), "FirstName" : "John", "LastName" : "Smith" } { "_id" : ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
766 Views
You can use dot(.) notation to read a specific key-value pair from MongoDB collection. Let us first create a collection with documents −> db.readSpecificKeyValueDemo.insertOne( ... { ... "_id": 100, ... "StudentDetails": ... { ... "StudentFirstName" : "David", ... "StudentLastName" :"Miller", ... "StudentAge":23, ... "StudentCountryName":"US" ... } ... } ... ); { "acknowledged" : true, "insertedId" : 100 }Following is the query to display all documents from the collection with the ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
899 Views
You can use aggregate framework along with $setUnion operator. Let us first create a collection with documents −> db.removeDuplicatesDemo.insertOne({"InstructorName":"Chris", "InstructorAge":34, "InstructorSubject": ["Java", "C", "Java", "C++", "MongoDB", "MySQL", "MongoDB"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9d96c895c4fd159f80807") }Following is the query to display all documents from the collection with the help of find() method −> db.removeDuplicatesDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cb9d96c895c4fd159f80807"), "InstructorName" : "Chris", "InstructorAge" : 34, "InstructorSubject" : [ "Java", "C", "Java", "C++", "MongoDB", ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
101 Views
You can use $all operator. Let us first create a collection with documents −> db.subsetOfAnArrayDemo.insertOne({"StudentProgrammingSkills": ["Java", "MongoDB", "MySQL", "C++", "Data Structure", "Algorithm", "Python", "Oracle", "SQL Server"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9d1e1895c4fd159f80804") }Following is the query to display all documents from the collection with the help of find() method −> db.subsetOfAnArrayDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cb9d1e1895c4fd159f80804"), "StudentProgrammingSkills" : [ "Java", "MongoDB", "MySQL", "C++", "Data Structure", "Algorithm", "Python", ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
360 Views
To extract the subarray value in MongoDB, you can use $elemMatch projection operator.Let us first create a collection with documents −> db.extractSubArrayDemo.insertOne( ... { ... _id: 101, ... "clientName":"Larry", ... "ClientDetails": ... [ ... { ... "ClientProjectName":"Online Game", ... "DeveloperTeamSize": 10 ... }, ... { ... "ClientProjectName":"Pig Dice Game", ... "DeveloperTeamSize": ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
594 Views
You can use aggregate framework along with $month projection operator. Let us first create a collection with documents −> db.specificMonthDemo.insertOne({"StudentName":"Larry", "StudentDateOfBirth":new ISODate('1995-01-12')}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9a9ca8f1d1b97daf71819") } > db.specificMonthDemo.insertOne({"StudentName":"Chris", "StudentDateOfBirth":new ISODate('1999-12-31')}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9a9db8f1d1b97daf7181a") } > db.specificMonthDemo.insertOne({"StudentName":"David", "StudentDateOfBirth":new ISODate('2000-06-01')}); { "acknowledged" : true, "insertedId" : ObjectId("5cb9a9ee8f1d1b97daf7181b") }Following is the query to display all documents from the collection with the help of find() method −> db.specificMonthDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cb9a9ca8f1d1b97daf71819"), "StudentName" : "Larry", "StudentDateOfBirth" : ISODate("1995-01-12T00:00:00Z") } { "_id" ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
153 Views
To add a value to the top of an array in MongoDB, you can use unshift() −yourArrayName.unshift("yourValue");The above syntax will add the value to the top of an array in MongoDB. Let us first create an array of strings −> technicalSkills=["Java", "MySQL", "C", "SQL SERVER", "ORACLE", "PL/SQL"];This will produce the following output −[ "Java", "MySQL", "C", "SQL SERVER", "ORACLE", "PL/SQL" ]Following is the query to add to the top of an array in MongoDB. Here, we will add “MongoDB” to top of an array using unshift() −> technicalSkills.unshift("MongoDB"); This will produce the following output −7Let us check the “MongoDB” has ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
90 Views
Let us first create a collection with documents −> db.likeDemo.insertOne({"Name":"John", Age:32}); { "acknowledged" : true, "insertedId" : ObjectId("5cb84984623186894665ae41") } > db.likeDemo.insertOne({"Name":"Chris", Age:25}); { "acknowledged" : true, "insertedId" : ObjectId("5cb84991623186894665ae42") } > db.likeDemo.insertOne({"Name":"Carol", Age:22}); { "acknowledged" : true, "insertedId" : ObjectId("5cb849a1623186894665ae43") } > db.likeDemo.insertOne({"Name":"Johnny", Age:22}); { "acknowledged" : true, "insertedId" : ObjectId("5cb849b2623186894665ae44") } > db.likeDemo.insertOne({"Name":"James", Age:27}); { "acknowledged" : true, "insertedId" : ObjectId("5cb849bb623186894665ae45") }Following is the query to display all documents from the collection with the help of find() method −> db.likeDemo.find().pretty();This will produce the following output −{ "_id" : ... Read More