Are there computed fields in MongoDB?
<p>Are there computed fields in MongoDB?</p>

<p>In SQL I can do:</p>

<pre><code>SELECT A+B AS C FROM MYTABLE WHERE C&gt;10
</code></pre>

<p>Can I do something similar in MongoDB?</p>

<p><strong>UPDATE</strong></p>

<p>I did with projection:</p>

<pre><code>db.segments.aggregate(
   [
      {
         $project: {
            "_id": 1,
            numberOfRestrictions: { $size: "$Speed Restrictions" }
         }
      }
   ]
)
</code></pre>

<p>and it works.</p>

<p>Unfortunately, further pipelining does not:</p>

<pre><code>db.segments.aggregate(
   [
      {
         $project: {
            "_id": 1,
            numberOfRestrictions: { $size: "$Speed Restrictions" }
         }
      },
      {
        $match: {
            "numberOfRestrictions": {
                "$gt": 1
            }
        }
      }
   ]
)
</code></pre>

<p>Latter causes error </p>

<pre><code>The argument to $size must be an Array, but was of type: EOO
</code></pre>