- 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
How to get a saved object in MongoDB?
Let us first create a variable. Following is the query −
> var studentDetails={"StudentFirstName":"Chris","StudentLastName":"Brown","StudentAge":24};
Following is the query to save records using save() −
> db.demo45.save(studentDetails); WriteResult({ "nInserted" : 1 })
Display all documents from a collection with the help of find() method −
> studentDetails;
This will produce the following output −
{ "StudentFirstName" : "Chris", "StudentLastName" : "Brown", "StudentAge" : 24, "_id" : ObjectId("5e25dab4cfb11e5c34d898ec") }
Advertisements