title: Understanding exports in NodeJS
body: <p>I don't think I quite understand how <code>exports</code> work in <em>Node.js</em>. In a bit of sample code, I noticed the <code>exports</code> object used in this manner:</p>
  
  <pre><code>exports = mongoose = require('mongoose')
  mongoose.connect(config.db.uri)
  exports = Schema = mongoose.Schema
  </code></pre>
  
  <p>What is happening behind the scenes when you use <code>exports =</code> twice like that? Looks to me like "mongoose" should not be exported. I did this quick test:</p>
  
  <pre><code>var foo
    , bar
  
  exports = foo = 'foo'
  exports = bar = 'bar'
  
  // reports 'bar' only
  console.log(exports)
  </code></pre>
  
  <p>and the second test does overwrite the first export.</p>