
- 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
How to 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.
- Related Articles
- Get output of MongoDB shell script?
- Use result from MongoDB in shell script?
- How to execute a script when I terminate a Docker container?
- What is Shell Script?
- How to unset a variable in MongoDB shell?
- How to Count Word Occurrences in a Text File using Shell Script?
- Aborting a shell script on any command fails
- Storing a Command in a Variable in a Shell Script
- How to print document value in MongoDB shell?
- How to define aliases in the MongoDB Shell?
- Running a Shell Script on a Remote Machine Through SSH
- Showing a GUI Notification From a Shell Script in Linux
- How to terminate javascript forEach()?
- How to print to console an object in a MongoDB script?
- How to run MongoDB shell using mongos command?\n

Advertisements