Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe this is NOT what your looking for, now that I read your question again: <a href="http://docs.mongodb.org/manual/applications/server-side-javascript/" rel="nofollow">http://docs.mongodb.org/manual/applications/server-side-javascript/</a></p> <p>Instead you are looking to modify the console in such a manner to make your life easier.</p> <p>I should note, right now, that there is actually an extension which can do this sort of auto-formatting for you made by 10gen: <a href="https://github.com/TylerBrock/mongo-hacker" rel="nofollow">https://github.com/TylerBrock/mongo-hacker</a></p> <p>However if you wish to modify the files behind MongoDBs console a little more then you will need to do some manual labour.</p> <p>There is a <code>rc</code> script in your home directory called <code>.mongorc.js</code>. In this file you can place any custom code you like (as @Asya mentioned) and it will actually become a command within the console.</p> <p>In you <code>rc</code> file you could place a function like:</p> <pre><code>DB.prototype.pfind = function(col){ return this[col].find().pretty(); }; </code></pre> <p>Or you could write:</p> <pre><code>DBCollection.prototype.pfind = function(){ return this.find().pretty(); }; </code></pre> <p>Then you should be able to do:</p> <pre><code>db.pfind('users'); </code></pre> <p>Or with the second command:</p> <pre><code>db.users.pfind(); </code></pre> <p>Of course this method is for Linux, I am unsure about Windows, however, Windows should have an <code>rc</code> type script somewhere I believe.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload