java mongo 查询统计 distinct


Date lastExcTime=new Date();


CommandResult result = mongoTemplate.getDb().command(

new BasicDBObject("distinct", "homeLog").append("key",

"userId").append(

"query",

new BasicDBObject("createTime", new BasicDBObject(

"$gte", lastExcTime))));

JSONArray bean=JSONArray.parseArray(result.getString("values"));

                        System.out.println(bean.size());


你可能感兴趣的:(java mongo 查询统计 distinct)