我在 MongoDB 有一个名为 resource 的集合。它有以下文件:
{ "_id" : "Abb.e", "_class" : "Resource", "resourceEmail" : "test1@test.com" }
{ "_id" : "Dasd.tt", "_class" : "Resource","resourceEmail" : "test2@test.com" }
{ "_id" : "Bbb.rr", "_class" : "Resource", "resourceEmail" : "test3@test.com" }
在 Java 代码中,我将它们列出如下:
MongoOperations mongoOperations = mongoConfiguration.getMongoTemplate();
List<Resource> resourceList = mongoOperations.findAll(Resource.class);
return resourceList;
我如何获取这些按 ID 排序的文档!