title: How can I convert string to number in mongoDb using $project in aggregation?
body: <p>I'm new mongoDB user, I just want to convert string field value to (int, float or long) to be able to do some comparisons and assign the result to a new field.<br>
  I couldn't, I have been trying for hours.<br>
  Here's what I want to do:  </p>
  
  <pre><code>// after doing $match and other projections and want to do last one $project 
  // P.S: $X values has been assigned in previous $project
  {
      $project:
      {
          xNumAsStr: "$X.NumAsStr",
          xNum: NumberInt("$X.NumAsStr"),
          result: NumberInt("$X.NumAsStr") &gt; 2000 ? "SomeStr" : "AnotherStr"
      }
  }
  </code></pre>
  
  <p>For sure what I'm doing is not correct, the main idea is I want to do some calculations and comparisons, I don't know them because will be dynamic (entered by a user in UI).<br>
  Is there a way to do it like in SQL world:  </p>
  
  <pre><code>SELECT CASE
           WHERE (some comparisons and math ops here) THEN 'ResultHere'
           ELSE 'NoResult'
         END
  </code></pre>
  
  <p><strong>UPDATE</strong>
  Is there a way to use JS functions to do what I want ?</p>