mongo-parse icon indicating copy to clipboard operation
mongo-parse copied to clipboard

Queries with $expr are not fully implemented

Open tlhunter opened this issue 5 years ago • 1 comments

Consider the following query:

{
    $expr: {
       $lt:[ {
          $cond: {
             if: { $gte: ["$qty", 100] },
             then: { $divide: ["$price", 2] },
             else: { $divide: ["$price", 4] }
           }
       },
       5 ]
  }
}

The expected result would contain fields for price and qty. Instead the results for for a field named $expr:

RESULT {
  "parts": [
    {
      "field": "$expr",
      "operator": "$lt",
      "operand": [
        {
          "$cond": {
            "if": {
              "$gte": [
                "$qty",
                100
              ]
            },
            "then": {
              "$divide": [
                "$price",
                2
              ]
            },
            "else": {
              "$divide": [
                "$price",
                4
              ]
            }
          }
        },
        5
      ],
      "parts": []
    }
  ]
}

tlhunter avatar Nov 05 '18 22:11 tlhunter

Thanks for the note. Yeah mongo-parse doesn't support $expr at all at the moment. I'd be happy to accept a pull request for it tho!

fresheneesz avatar Nov 05 '18 23:11 fresheneesz