Join mongodb collections in Mule

93 views Asked by At

In Mule, how can I join applicable Product and Employee mongodb documents to each Store document in the collection or is there a better approach to retrieving information from 3 collections and populating a main JSON object in Mule?

I have three mongoDB collections:

  1. Store
  2. Product
  3. Employee

The Store collection has references to Products and Employee collections.

Using Mule I would like to:

  1. Retrieve the documents in the Store collection
  2. Retrieve all of the Products referenced by productId array field in each Store document
  3. Retrieve all of the Employees referenced by employeeId array field in each Store document

The result I am looking for is something like this:

{
    "stores": [{
        "storeId": "1234A",
        "name": "Store 1",
        "products": [{
            "productId": "ABCDEF1",
            "productName": "Phone",
            "price": 100.00
        }],
        "employees": [{
            "employeeId": "EMP1",
            "employeeName": "John",
            "dept": "sales"
        }]

    }]
}

Thanks

0

There are 0 answers