
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
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
- Related Articles
- What is the difference between deleteOne() and findOneAndDelete() operation in MongoDB?
- What is the TFTP Operation?
- How to execute a command and get the output of command within C++ using POSIX?
- How to work with Invoke-Command Scriptblock output?
- What does the max field mean in the output of MongoDB db..stats( )?
- Get output of MongoDB shell script?
- Query in MongoDB to perform an operation similar to LIKE operation
- How to convert command output to the Hashtable format in PowerShell?
- How to execute a command and get output of command within C++ using POSIX?
- What is the BSON query for the command 'show dbs' (list of databases) in MongoDB?
- How to exclude the RunSpaceID property from the Invoke-Command output in PowerShell?
- What is PHP Output Buffering?
- How to Save Command Output to a File in Linux?
- Difference between Write-Output and Write-Host command in PowerShell?
- Pass the Output of a Command as an Argument for Another on Linux

Advertisements