mongo基本操作

xiaoxiao2021-02-28  126

//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());
转载请注明原文地址: https://www.6miu.com/read-27691.html

最新回复(0)