Mondo Db. Pipeline Lookup doesn't work as usual.. why?

Viewed 16

I need to enhance my regular working lookup. Initial one (working) looks like this:

 '$lookup': {
      'from': 'supplier_products', 
      'localField': 'purchase_order_items.supplierProductId', 
      'foreignField': '_id', 
      'as': 'supplier_products'
    }

Enhanced one (not working) looks like this:

'$lookup': {
      'from': 'supplier_products', 
      'let': {
        'id': '$purchase_order_items.supplierProductId'
      }, 
      'pipeline': [
        {
          '$match': {
            '$expr': {
              '$eq': [
                '$$id', '$_id'
              ]
            }
          }
        }
      ], 
      'as': 'supplier_products'
    }

Second one supposes to response same array of data, but responses an empty array. (supplier_products = []). What is wrong with my second request?

0 Answers
Related