Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid printing output in mongo client

Tags:

mongodb

I am working with mongo client. Sometimes the output of some commands I execute involve an enormous output, which mongo prints on screen. How can I avoid this?

like image 586
Muhammad Waqar Avatar asked May 07 '13 19:05

Muhammad Waqar


2 Answers

There is a way to suppress output. Using "var x = ...;" allows to hide output of expressions. But there are other commands that harder to suppress like

Array.prototype.distinct = function() {
   return [];
}

This produces printing of new defined function. To suppress it you will need to write it in this way:

var suppressOutput = (
   Array.prototype.distinct = function() {
      return [];
   }
);
like image 76
Andrey Hohutkin Avatar answered Nov 03 '22 20:11

Andrey Hohutkin


Per the comment by @WiredPrairie, this solution worked for me:

Just set the return value to a local variable: var x=db.so.find(); and inspect it as needed.

like image 32
Muhammad Waqar Avatar answered Nov 03 '22 21:11

Muhammad Waqar