我有一个独特的查询来从db获取元素列表。 我怎样才能实现这个方法只获得元素的数量 - 第二种方法:
public List distinctElementsByParam(Object param) {
String collName = mongoOperations.getCollectionName(MyClass.class);
DBCollection collection = mongoOperations.getCollection(collName);
BasicDBObject query = new BasicDBObject();
query.put("mDBField", param);
return collection.distinct("myDistinctDBField", query);
}
public long distinctCountByParam(Object param) {
String collName = mongoOperations.getCollectionName(MyClass.class);
DBCollection collection = mongoOperations.getCollection(collName);
BasicDBObject query = new BasicDBObject();
query.put("mDBField", param);
return ????;
}