mrwadepro
mrwadepro

Reputation: 279

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

Upvotes: 6

Views: 11465

Answers (1)

Amoury
Amoury

Reputation: 133

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

Upvotes: 11

Related Questions