- 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
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
242 Views
To know which storage engine is used in MongoDB, you can use storageEngine. The syntax is as follows −db.serverStatus().storageEngine;To know all the configuration details of storage engine, you can use the following syntax:db.serverStatus().yourStorageEngineName;Let us implement the above syntax to know which storage engine is being used in MongoDB. The query is as follows −> db.serverStatus().storageEngine;The following is the output −{ "name" : "wiredTiger", "supportsCommittedReads" : true, "supportsSnapshotReadConcern" : true, "readOnly" : false, "persistent" : true }In order to know all configuration details about the above storage engine, the query is as follows −> db.serverStatus().wiredTiger;The following ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
245 Views
To get distinct list of sub-document field values, you can use dot(.). The syntax is as follows −db.yourCollectionName.distinct("yourOuterFieldName.yourInnerFieldName");To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.getDistinctListOfSubDocumentFieldDemo.insertOne( ... { ... "StudentId": 101, ... "StudentPersonalDetails": [ ... { ... "StudentName": "John", ... "StudentAge":24 ... }, ... { ... ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
190 Views
You can use aggregate() method along with $sort() operator for this. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.aggregationSortDemo.insertOne({"StudentId":98, "StudentFirstName":"John", "StudentLastName":"Smith"}); { "acknowledged" : true, "insertedId" : ObjectId("5c90140c5705caea966c5587") } > db.aggregationSortDemo.insertOne({"StudentId":128, "StudentFirstName":"Carol", "StudentLastName":"Taylor"}); { "acknowledged" : true, "insertedId" : ObjectId("5c90141b5705caea966c5588") } > db.aggregationSortDemo.insertOne({"StudentId":110, "StudentFirstName":"David", "StudentLastName":"Miller"}); { "acknowledged" : true, "insertedId" : ObjectId("5c90142f5705caea966c5589") } > db.aggregationSortDemo.insertOne({"StudentId":139, "StudentFirstName":"Chris", "StudentLastName":"Brown"}); { "acknowledged" : true, "insertedId" : ObjectId("5c90146a5705caea966c558a") } > db.aggregationSortDemo.insertOne({"StudentId":125, "StudentFirstName":"Sam", "StudentLastName":"Williams"}); { "acknowledged" : true, ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
333 Views
You can use $in operator for this. Let us first create a collection with a document. The query to create a collection with a document is as follows −> db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":1, "StudentName":"Larry"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9010215705caea966c557f") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":2, "StudentName":"Mike", "hasAgeGreaterThanOrEqualTo18":true}); { "acknowledged" : true, "insertedId" : ObjectId("5c90106a5705caea966c5580") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":3, "StudentName":"Carol", "hasAgeGreaterThanOrEqualTo18":false}); { "acknowledged" : true, "insertedId" : ObjectId("5c9010795705caea966c5581") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":4, "StudentName":"Sam", "hasAgeGreaterThanOrEqualTo18":null}); { "acknowledged" : true, "insertedId" : ObjectId("5c9010865705caea966c5582") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":5, "StudentName":"David", "hasAgeGreaterThanOrEqualTo18":false}); { "acknowledged" : true, "insertedId" : ObjectId("5c9010945705caea966c5583") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":6, "StudentName":"Chris", ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
568 Views
To print unpretty json, use the following syntax −var yourVariableName= db.yourCollectionName.find().sort({_id:-1}).limit(10000); while( yourVariableName.hasNext() ) { printjsononeline(yourVariableName.next() ); };To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.unprettyJsonDemo.insertOne({"StudentName":"John", "StudentAge":21, "StudentTechnicalSkills":["C", "C++"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c900df25705caea966c557d") } > db.unprettyJsonDemo.insertOne({"StudentName":"Carol", "StudentAge":22, "StudentTechnicalSkills":["MongoDB", "MySQL"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c900e085705caea966c557e") }all documents from a collection with the help of find() method. The query is as follows −> db.unprettyJsonDemo.find().pretty();The following is the output −{ "_id" : ObjectId("5c900df25705caea966c557d"), ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
845 Views
To get the highest value of a column in MongoDB, you can use sort() along with limit(1). The syntax is as follows −db.yourCollectionName.find().sort({"yourFieldName":-1}).limit(1);To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.gettingHighestValueDemo.insertOne({"Value":1029}); { "acknowledged" : true, "insertedId" : ObjectId("5c900b885705caea966c5574") } > db.gettingHighestValueDemo.insertOne({"Value":3029}); { "acknowledged" : true, "insertedId" : ObjectId("5c900b8d5705caea966c5575") } > db.gettingHighestValueDemo.insertOne({"Value":1092}); { "acknowledged" : true, "insertedId" : ObjectId("5c900b925705caea966c5576") } > db.gettingHighestValueDemo.insertOne({"Value":18484}); { "acknowledged" : true, "insertedId" : ObjectId("5c900b955705caea966c5577") } > db.gettingHighestValueDemo.insertOne({"Value":37474}); { "acknowledged" ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
119 Views
You can use $where operator for this. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.queryInSameDocumentsDemo.insertOne({"StudentDetails":{"StudentName":"John"}, "NewStudentDetails":{"StudentName":"Carol"}}); { "acknowledged" : true, "insertedId" : ObjectId("5c90096ed3c9d04998abf017") } > db.queryInSameDocumentsDemo.insertOne({"StudentDetails":{"StudentName":"Bob"}, "NewStudentDetails":{"StudentName":"Bob"}}); { "acknowledged" : true, "insertedId" : ObjectId("5c900a435705caea966c5573") }Display all documents from a collection with the help of find() method. The query is as follows −> db.queryInSameDocumentsDemo.find().pretty();The following is the output −{ "_id" : ObjectId("5c90096ed3c9d04998abf017"), "StudentDetails" : { "StudentName" : "John" }, "NewStudentDetails" : { ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
1K+ Views
The syntax is as follows for this −db.yourCollectionName.update({ }, { $set: { "yourOuterFieldName.yourInnerFieldName": "yourValue" } });To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.updateNestedValueDemo.insertOne({"CustomerName":"Chris", ... "CustomerDetails":{"CustomerAge":25, "CustomerCompanyName":"Google", "CustomerCityName":"US"}}); { "acknowledged" : true, "insertedId" : ObjectId("5c8fccc4d3c9d04998abf015") }Display all documents from a collection with the help of find() method. The query is as follows −> db.updateNestedValueDemo.find().pretty();The following is the output −{ "_id" : ObjectId("5c8fccc4d3c9d04998abf015"), "CustomerName" : "Chris", "CustomerDetails" : { "CustomerAge" : 25, ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
1K+ Views
To get the list of all values of certain fields in MongoDB, you can use distinct(). The syntax is as follows −db.yourCollectionName.distinct( "yourFieldName");To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.listAllValuesOfCeratinFieldsDemo.insertOne({"ListOfValues":[10, 20, 30]}); { "acknowledged" : true, "insertedId" : ObjectId("5c8fc89ed3c9d04998abf011") } > db.listAllValuesOfCeratinFieldsDemo.insertOne({"ListOfValues":[40, 50, 60]}); { "acknowledged" : true, "insertedId" : ObjectId("5c8fc8abd3c9d04998abf012") } > db.listAllValuesOfCeratinFieldsDemo.insertOne({"ListOfValues":[10, 20, 30]}); { "acknowledged" : true, "insertedId" : ObjectId("5c8fc8d7d3c9d04998abf013") } > db.listAllValuesOfCeratinFieldsDemo.insertOne({"ListOfValues":[40, 50, 70]}); { "acknowledged" : true, "insertedId" ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
366 Views
To create nested index in MongoDB, you can use createIndex() or ensureIndex(). The syntax is as follows −db.yourCollectionName.createIndex({"yourOuterFieldName.yourInnerFieldName.yourSecondInnerFieldName": 1});To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.nestedIndexDemo.insertOne( ... { ... ... "CustomerId":101, ... "CustomerDetails": ... { ... "CustomerListDetails": ... { ... "CustomerName":"Larry", ... "CustomerProjectName": "Project-1", ... Read More