
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
Found 1661 Articles for Big Data Analytics

144 Views
To query MongoDB using the $ne operator, following is the syntax −db.yourCollectionName.find({yourFieldName:{$ne:yourValue}}).pretty();Let us create a collection with documents −> db.notEqaulToDemo.insertOne({"StudentName":"Larry", "StudentMathMarks":68}); { "acknowledged" : true, "insertedId" : ObjectId("5cbd3a6bde8cc557214c0ded") } > db.notEqaulToDemo.insertOne({"StudentName":"Chris", "StudentMathMarks":88}); { "acknowledged" : true, "insertedId" : ObjectId("5cbd3a79de8cc557214c0dee") } > db.notEqaulToDemo.insertOne({"StudentName":"David", "StudentMathMarks":45}); { "acknowledged" : true, "insertedId" : ObjectId("5cbd3a89de8cc557214c0def") } > db.notEqaulToDemo.insertOne({"StudentName":"Carol", "StudentMathMarks":69}); { "acknowledged" : true, "insertedId" : ObjectId("5cbd3a97de8cc557214c0df0") }Display all documents from a collection with the help of find() method −> db.notEqaulToDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cbd3a6bde8cc557214c0ded"), "StudentName" : "Larry", "StudentMathMarks" : ... Read More

167 Views
Use $unset operator to unset an attribute. Let us first create a collection with documents −> db.unsetAnAttributeDemo.insertOne( ... { ... _id: 1, ... "StudentDetails": [ ... { ... "StudentFirstName": "Ramit", ... "StudentCountryName":"UK" ... }, ... { ... "StudentFirstName": "Bob", ... "StudentCountryName":"US" ... }, ... { ... ... Read More

243 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

191 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

445 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

919 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

1K+ 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

147 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

424 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

691 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