spring-data-mongodb查询结果返回指定字段
方法1
DBObject dbObject = new BasicDBObject();
dbObject.put("status", 1);
DBObject fieldObject = new BasicDBObject();
fieldObject.put("catalogName", true);
fieldObject.put("_id", true);
Query query = new BasicQuery(dbObject, fieldObject);
return MongoPagebleUtil.queryAndPagable(query, pageable, getMongoOperations(), ForeCatalog.class);
方法2
@Query(value = "{'status':?0 }", fields = "{ '_id' : 1, 'catalogName' : 1}")
List<ForeCatalog> findAllForeCatalogIdAndName(String status);