如何在mule中执行mongodb run命令?

时间:2016-02-19 06:21:22

标签: mongodb mule

我在mongodb中尝试这个命令:

db.runCommand ( { distinct: "user", key: "city" } )

并获得了适当的数据。

我想在mule中传递此命令。我在我的骡子流中尝试这个:

<mongo:execute-command config-ref="Mongo_DB_Go"   doc:name="Mongo DB"  database="test" username="${db.user}" commandName="distinct" commandValue='{distinct : &quot;user&quot;, key : &quot;city&quot; }'/>

2 个答案:

答案 0 :(得分:0)

该连接器的文档和示例有点缺乏,以下是应该如何:

    <mongo:execute-command config-ref="Mongo_DB" commandName="distinctCommand" doc:name="Mongo DB" commandValue="function(){db.runCommand ( { distinct: &quot;user&quot;, key: &quot;city&quot; } )}"/>

答案 1 :(得分:0)

<mongo:execute-command config-ref="Mongo_DB" commandName="eval" commandValue="db.runCommand({distinct: &quot;user&quot;, key: &quot;city&quot;})" doc:name="Mongo DB"/>

它可能是过度工程,但却是我得到的最快的解决方案。