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:
- Store
- Product
- Employee
The Store collection has references to Products and Employee collections.
Using Mule I would like to:
- Retrieve the documents in the Store collection
- Retrieve all of the Products referenced by productId array field in each Store document
- 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