Is there a way to read a line from the Mongo shell? readline()
is not defined and neither is system.stdin
.
I need to do this in interactive mode, as opposed to feeding input to a script executed by the MongoDB shell.
To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.
Use connect() to Connect to a MongoDB Instance You can also use the connect() method to connect to the MongoDB instance. The following command: Connects to the MongoDB instance that is running on localhost with the non-default port 27020 , and. Sets the global db variable.
MongoDB Mongo shell is the default client for the MongoDB database server. It's a command-line interface (CLI), where the input and output are all console-based. The Mongo shell is a good tool to manipulate small sets of data.
Use the db. collection. find() method in the MongoDB Shell to query documents in a collection.
Per @Stennie's comment, this is not possible right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With