專案用的MongoDB要改為分布式的,有人說程式里有用到group統計的要改代碼,集群環境下不支持。代碼如下
DBObject _match = new BasicDBObject();
_match.put("MAIN_TAG","0");
_aggregate.add(new BasicDBObject("$match", _match));
DBObject _group = new BasicDBObject();
DBObject _id = new BasicDBObject();
_id.put("SUPER_ID", "$SUPER_ID");
_group.put("_id", _id);
_group.put("COUNT", new BasicDBObject("$sum", 1));
_aggregate.add(new BasicDBObject("$group", _group));
AggregationOutput output = mongodbTemplate.getDB("xxx").getCollection("xxxxx").aggregate(_aggregate);
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/81779.html
標籤:MongoDB
