连接
find
,
sort
如此这般肯定行得通,
但是
只有
find()
实际上是在数据库端执行的,它将返回结果,然后应用程序将对其应用排序。
如果要创建一个查询来执行数据库端的所有操作,则需要
pipeline
. 要做到这一点,你可以使用
Aggregation Framework
java驱动程序的
collection.aggregate(
Arrays.asList(
match(eq("functionalityName", "specificValue")),
sort(descending("date")),
project(fields(include("date")))
)
)
In the documentation
您可以找到可以应用于管道的所有阶段。