title: Project boolean value in aggregation framework
body: <p>Is it possible to <code>project</code> the boolean value of an operation with MongoDB's aggregation framework?</p>
  
  <p>For example, given an input document like so:</p>
  
  <pre><code>{
    "id": 123,
    "data": [
      {
        "val": 1
      },
      {
        "val": 2
      },
      {
        "val": 3
      },
      {
        "val": 4
      },
      {
        "val": 5
      }
    ]
  }
  </code></pre>
  
  <p>And the operation being <code>$data.val &gt; 3</code> I'd like to return:</p>
  
  <pre><code>{
    "result": [
      {
        "bool_val": 0
      },
      {
        "bool_val": 0
      },
      {
        "bool_val": 0
      },
      {
        "bool_val": 1
      },
      {
        "bool_val": 1
      }
    ],
    "ok": 1
  }
  </code></pre>
  
  <p>This is what I came up with: </p>
  
  <pre><code>db.test.aggregate([{$match: {id: 123}}, 
                     {$unwind: "$data"}, 
                     {$project: {"bool_val": {"$data.val": {$gt: 3}}, _id: 0}} 
                    ]) 
  </code></pre>
  
  <p>Which produces the following error:</p>
  
  <pre><code>aggregate failed: {
    "errmsg": "exception: invalid operator '$data.val'", 
    "code": 15999,
    "ok": 0
  } 
  </code></pre>