mongo基本操作

来源:互联网 发布:米拉奇战记无敌版软件 编辑:程序博客网 时间:2024/06/05 05:29
//1.分组查询Aggregation agg=Aggregation.newAggregation(                Aggregation.match(Criteria.where("tenantId").is(TenantUtils.getTenantId()).and("ancestor._id").is(id).and("vmallOnShelf").is(true)),                Aggregation.group("goodsId").push(Aggregation.ROOT).as("goodsList").first("vmallPrice").as("vmallPrice"),                Aggregation.sort(direction, "vmallPrice"),                Aggregation.skip(m),                Aggregation.limit(n)            );        List<GoodsSKU> list = mongoTemplate.aggregate(agg,"goods", GoodsSKU.class).getMappedResults();        return list.stream().map(GoodsSKU::getFirstGoods).collect(Collectors.toList());
原创粉丝点击