如何在 mule 中对 mongo 数据库记录进行排序
How to sort mongo db records in mule
我正在使用 Anypoint studio (v6.1.3) 和 Mule 3.8.0 CE 运行时。
我想从一个集合中获取对象,使用从数据库中查找对象选项。有一个选项可以给排序参考。当我 googled 时,我发现我必须在该字段中提供 org.bson.Documet 对象。它对我不起作用。
尝试在 google 中搜索,但没有找到教程或博客。在mule网站上,没有正确的解释。
您可以传递 #[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("_id",-1)]" doc:name="Mongo DB"/>
希望对您有所帮助。
我正在使用 Anypoint studio (v6.1.3) 和 Mule 3.8.0 CE 运行时。
我想从一个集合中获取对象,使用从数据库中查找对象选项。有一个选项可以给排序参考。当我 googled 时,我发现我必须在该字段中提供 org.bson.Documet 对象。它对我不起作用。
尝试在 google 中搜索,但没有找到教程或博客。在mule网站上,没有正确的解释。
您可以传递 #[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("_id",-1)]" doc:name="Mongo DB"/>
希望对您有所帮助。