Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go to next line while in MongoDB shell?

I am taking a MongoDB course on Lynda and the instructor goes to a new line while entering javascript code. How is this accomplished? I am talking about the lines she went to with the ellipsis "..."enter image description here

like image 362
mrwadepro Avatar asked Mar 30 '18 20:03

mrwadepro


People also ask

How do I move to the next line in MongoDB?

Multi-Line Operations in the Embedded MongoDB Shell To write an operation that spans multiple lines in the embedded mongosh , begin with the first line, then press Shift + Enter to move to the next line of code.

How use MongoDB command line?

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.

Can we run queries in MongoDB compass?

Yes, Mongo compass provides only filter option(Query Bar) to do queries on specific collection.

What is Run command in MongoDB?

Definition. db.runCommand(command) Provides a helper to run specified database commands. This is the preferred method to issue database commands, as it provides a consistent interface between the shell and drivers. Parameter.


1 Answers

If you end a line with an open parenthesis ('('), an open brace ('{'), or an open bracket ('['), then the subsequent lines start with ellipsis ("...") until you enter the corresponding closing parenthesis (')'), the closing brace ('}') or the closing bracket (']'). The mongo shell waits for the closing parenthesis, closing brace, or the closing bracket before evaluating the code, as in the following example:

> if ( x > 0 ) {
... count++;
... print (x);
... }

The can find more details on https://docs.mongodb.com/manual/mongo/#multi-line-operations-in-the-mongo-shell

like image 180
Amoury Avatar answered Oct 31 '22 02:10

Amoury