- 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
Get output of MongoDB shell script?
You can use printjson() or print() to get output of MongoDB shell script. Let us create an array of objects.
Following is the query to create an array of objects.
> var studentDetails=[{"StudentName":"John","StudentAge":21}, {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];
Following is the query to get the output of Mongo shell script using printjson() −
> printjson(studentDetails);
This will produce the following output −
[ { "StudentName" : "John", "StudentAge" : 21 }, { "StudentName" : "Carol", "StudentAge" : 24 }, { "StudentName" : "David", "StudentAge" : 25 } ] > var studentDetails=[{"StudentName":"John","StudentAge":21}, {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];
Advertisements