Spring 数据 Mongo - 在没有嵌入文档的情况下引入分页数据

Spring Data Mongo - Bring Paginated Data without embedded document

我浏览了很多链接,例如:。我正在使用 Spring Boot v2.2.2.RELEASE + Spring Data Mongo例如。

我想让所有员工都有分页数据,但我不想带部门。

我需要在 Page<Employee> findAll(Pageable pageable); 中更改什么。

{
    "_id" : ObjectId("5e4143762d8c210ff48f1026"),
    "firstName" : "John",
    "lastName" : "Doe",
    .....
    ......
    ......
    .......
    "departments" : [ 
        {
            "departmentName" : "IT Department",
            "departmentCode" : "IT",
            ....
            ....
        }, 
         ....
         ....
    ]
}

我能够使用下面的 Spring Data Mongo.

查询来做到这一点
@Query(value = "{}", fields = "{'departments': 0}")
Page<Employee> findAll(Pageable pageable);