title: Mongoose Query: compare two values on same document
body: <p>How can I query a Mongo collection using Mongoose to find all the documents that have a specific relation between two of their own properties?</p>
  
  <p>For example, how can I query a <code>characters</code> collections to find all those characters that have their <code>currentHitPoints</code> value less than their <code>maximumHitPoints</code> value? Or all those <code>projects</code> that have their <code>currentPledgedMoney</code> less than their <code>pledgeGoal</code>?</p>
  
  <p>I tried to something like this:</p>
  
  <pre><code>mongoose.model('Character')
      .find({
          player: _currentPlayer
      })
      .where('status.currentHitpoints').lt('status.maximumHitpoints')
      .exec(callback)
  </code></pre>
  
  <p>but I am getting errors since the <code>lt</code> argument must be a <code>Number</code>. The same goes if I use <code>$.status.maximumHitpoints</code> (I was hoping Mongoose would be able to resolve it like it does when doing collection operations).</p>
  
  <p>Is this something that can be done within a Query? I would expect so, but can't find out how. Otherwise I can filter the whole collection with <code>underscore</code> but I suspect that is going to have a negative impact on performance.</p>
  
  <p>PS: I also tried using similar approaches with the <code>find</code> call, no dice.</p>