
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Terminate a MongoDB Shell Script Earlier
In order to terminate a MongoDB shell script earlier, you need to use quit. Following is the syntax
quit() quit(1)
Let us create a script and try to write quit() or quit(1) in shell. At first, we will create the following collection with documents
> db.flightInformation.insertOne({"FlightName":"Flight-1","ArrivalTime":new ISODate("2019-03-12")}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1e341e941bbb0e8bf5639") } > db.flightInformation.insertOne({"FlightName":"Flight-2","ArrivalTime":new ISODate("2019-03-31")}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1e351e941bbb0e8bf563a") }
Following is the query to display all documents from a collection with the help of find() method
> db.flightInformation.find().pretty();
This will produce the following output
{ "_id" : ObjectId("5ca1e341e941bbb0e8bf5639"), "FlightName" : "Flight-1", "ArrivalTime" : ISODate("2019-03-12T00:00:00Z") } { "_id" : ObjectId("5ca1e351e941bbb0e8bf563a"), "FlightName" : "Flight-2", "ArrivalTime" : ISODate("2019-03-31T00:00:00Z") } Following is the query to terminate a MongoDB shell script earlier: > quit();
This will produce the following output
C:\Users\Amit>
Look at the above sample output, this will terminate from MongoDB shell script.
Advertisements