- 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
MongoDB profiler output: What is the “command” operation?
The following operations are treated as command operation in MongoDB −
1.count 2.findAndModify 3.aggregate
Following is the example of count in MongoDB −
Let us create a collection with documents −
> db.demo443.insertOne({"Name":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5e78d281bbc41e36cc3caeb9") } > db.demo443.insertOne({"Name":"Bob"}); { "acknowledged" : true, "insertedId" : ObjectId("5e78d285bbc41e36cc3caeba") } > db.demo443.insertOne({"Name":"David"}); { "acknowledged" : true, "insertedId" : ObjectId("5e78d288bbc41e36cc3caebb") }
Display all documents from a collection with the help of find() method −
> db.demo443.find();
This will produce the following output −
{ "_id" : ObjectId("5e78d281bbc41e36cc3caeb9"), "Name" : "Chris" } { "_id" : ObjectId("5e78d285bbc41e36cc3caeba"), "Name" : "Bob" } { "_id" : ObjectId("5e78d288bbc41e36cc3caebb"), "Name" : "David" }
The MongoDB count example is as follows −
> db.demo443.count();
This will produce the following output −
3
Advertisements