简体   繁体   中英

How to fetch data from MongoDB in dataweave according to passing previous fields we transformed in Mule 4

How to fetch data from MongoDB in dataweave according to passing previous fields we transformed in Mule 4.

So After fetching data from one collection and while trasforming that data into Json I want to fecth data from other collection using current values of Json and add that data into same JSON.

More clear about question: I want to aggregate two collections data in one JSON which I will be insert back in MongoDB.

I'm not sure I would approach this the way your question is asked but it is possible. Take a look at this: https://anypoint.mulesoft.com/exchange/org.mule.examples/dataweave-with-flowreflookup/minor/2.1/ You will need to be able to log-in to view all the details.

A second option is to use what is called a lookup, it has some considerations so check the documentation carefully: https://docs.mulesoft.com/mule-runtime/4.3/dw-mule-functions-lookup

Final approach, perform your first query but direct the output to a variable not payload. You can access the input you need for your second query. Now you can use Dataweave as normal to construct the final output you need from your variable and the second query. HTH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM