如何在mule中对mongo db记录进行排序

时间:2016-10-08 11:37:40

标签: mule mongodb-query mule-component

我正在使用Anypoint studio(v6.1.3)和Mule 3.8.0 CE运行时。

我想使用db选项中的find对象从一个集合中获取对象。有一个选项可以提供排序参考。当我用Google搜索时,我发现我必须在该文件中提供 org.bson.Documet 对象。它对我没用。

尝试在谷歌搜索,但没有找到教程或博客。在mule网站上,没有适当的解释。

1 个答案:

答案 0 :(得分:1)

您可以传递#[new org.bson.Document("filedName",-1)]#[new com.mongodb.BasicDBObject("filedName",-1)]之类的内容进行排序。这里' filedName'是用于排序的字段名称,第二个参数1用于升序,-1用于降序

<mongo:find-documents config-ref="Mongo_DB__Configuration" collection="test" sortBy-ref="#[new org.bson.Document(&quot;_id&quot;,-1)]" doc:name="Mongo DB"/>

希望得到这个帮助。

相关问题