[英]WSO2 Mongo data service dynamic query parameter
i'm trying to create a mongo data service in WSO2EI. 我正在尝试在WSO2EI中创建mongo数据服务。 Currently I have this query, which gives me results based on componentId: 当前,我有此查询,它给我基于componentId的结果:
<query id="find" useConfig="MongoDB"> <expression>collection.find("{componentId : #}")</expression> <result outputType="json">{
"Documents": {
"Document": [
{
"Data": "$document"
}
]
}
}</result> <param name="componentId" sqlType="STRING"/> </query>
But I need to enter the parameter(s) dynamically to be able to .find different results based on parameter name I provided, something like this: 但是我需要动态输入参数,以便能够根据我提供的参数名称找到不同的结果,如下所示:
<query id="find" useConfig="MongoDB"> <expression>collection.find("{fieldName : #} : {fieldValue : #}")</expression> <result outputType="json">{
"Documents": {
"Document": [
{
"Data": "$document"
}
]
}
}</result> <param name="fieldName" sqlType="STRING"/> <param name="fieldValue" sqlType="STRING"/> </query>
Is this possible? 这可能吗? Or do I have to create multiple queries for each parameter? 还是我必须为每个参数创建多个查询?
Thanks 谢谢
Yes it's possible! 是的,有可能! Try this (work for me). 试试这个(为我工作)。
<query id="wesites_find_param" useConfig="mongo_ds">
<expression>websites.find("{#: #}")</expression>
<result element="Documents" rowName="Document" useColumnNumbers="true">
<element column="document" name="Data" xsdType="string"/>
</result>
<param defaultValue="name" name="par1" sqlType="STRING"/>
<param name="par2" sqlType="STRING"/>
</query>
<operation name="website_find_param_op">
<call-query href="wesites_find_param">
<with-param name="par1" query-param="par1"/>
<with-param name="par2" query-param="par2"/>
</call-query>
</operation>
<resource method="GET" path="/websitefind">
<call-query href="wesites_find_param">
<with-param name="par1" query-param="par1"/>
<with-param name="par2" query-param="par2"/>
</call-query>
</resource>
Example, 例,
?par1=componentId&par2=pippo
对于componentId:“ pippo”,请使用?par1=componentId&par2=pippo
?par1=componentName&par2=proxy_hl7
对于componentName:“ proxy_hl7”,请使用?par1=componentName&par2=proxy_hl7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.