Convert ArangoDB query to MongoDB query

16 Views Asked by At

My Arango Query:

FOR productDocument IN Product
FILTER productDocument.attributes.artDiff.values != null
FOR product_attributes_artdiff_valuesDocument IN TO_ARRAY(productDocument.attributes.artDiff.values)
FILTER product_attributes_artdiff_valuesDocument.data != null
FOR product_attributes_artdiff_values_dataDocument IN TO_ARRAY(product_attributes_artdiff_valuesDocument.data)
RETURN {""productDocument_identifier"": productDocument.identifier, ""product_attributes_artdiff_values_dataDocument_code"": product_attributes_artdiff_values_dataDocument.code}

There is three joins with the same Product document but diffrent sub documents.

I tried with sample join query, I am able to done some part but not able to complete. Need help:

db.Product.aggregate( 
  [
    {         
      $match: {
                productDocument.attributes.artDiff.values != null
              },     
    },     
    {     
      $lookup: {
                 from: 'worldEdges', 
                 localField: '_id', 
                 foreignField: '_to', 
                 as: 'toCities'
               }     
    }, 
    {
      $unwind: "$toCities"
    }, 
    {     
      $lookup: {
                 from: 'worldVertices', 
                 localField: 'toCities._from', 
                 foreignField: '_id', 
                 as: 'capital'
               }     
    }, 
    {
      $unwind: "$capital"
    }, 
    {
      $match: {
                "capital.type":"capital"
              }
    }, 
    {
      $project: {
                  _id: 0, 
                  name: 1, 
                  "capital.name": 1
                }
    }
  ] 
).pretty()
    
0

There are 0 best solutions below

Related Questions in ARANGO-MONGO