Muhammad Waqar
Muhammad Waqar

Reputation: 879

Avoid printing output in mongo client

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?

Upvotes: 9

Views: 4843

Answers (2)

Muhammad Waqar
Muhammad Waqar

Reputation: 879

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.

Upvotes: 2

Andrey Hohutkin
Andrey Hohutkin

Reputation: 2919

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 [];
   }
);

Upvotes: 9

Related Questions