![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Check the current number of connections to MongoDB?
You can check the current number of connections to MongoDB with the help of the following syntax −
var anyVariableName= db.serverStatus(); yourVariableName.connections;
The second syntax is as follows −
db.serverStatus().connections;
To understand both the above syntaxes, let us see them one by one −
Case 1 − The first query is as follows −
> var checkCurrentNumberOfConnections = db.serverStatus() > checkCurrentNumberOfConnections.connections;
The following is the output −
{ "current" : 1, "available" : 999999, "totalCreated" : 1 }
Case 2 − The second query is as follows −
> db.serverStatus().connections
The following is the output −
{ "current" : 1, "available" : 999999, "totalCreated" : 1 }
Advertisements