简体   繁体   English

如何根据传递我们在 Mule 4 中转换的先前字段从 dataweave 中的 MongoDB 获取数据

[英]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.如何根据传递我们在 Mule 4 中转换的先前字段从 dataweave 中的 MongoDB 获取数据。

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.因此,在从一个集合中获取数据并将该数据转换为 Json 之后,我想使用 Json 的当前值从其他集合中获取数据,并将该数据添加到相同的 Z0ECD11C1D7A287401D148A2F8

More clear about question: I want to aggregate two collections data in one JSON which I will be insert back in MongoDB.更清楚的问题:我想在一个 JSON 中聚合两个 collections 数据,我将在 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.看看这个: https://anypoint.mulesoft.com/exchange/org.mule.examples/dataweave-with-flowreflookup/minor/2.1/您需要能够登录才能查看所有详细信息。

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第二种选择是使用所谓的查找,它有一些注意事项,因此请仔细检查文档: 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.最后一种方法,执行您的第一个查询,但将 output 指向变量而不是有效负载。 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.现在您可以照常使用 Dataweave 从变量和第二个查询中构造您需要的最终 output。 HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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