Multi-line operations in the mongo shell

How to enter multi-line operations in the mongo shell?

In mongo shell, 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.

if ( x > 0 )

{
… count++;

… print (x);
… }

You can exit the line continuation mode if you enter two blank lines as shown below:

if (x > 0)