javamongodb批量更新_java中mongoTemplate批量更新⽅法:Db().getCollection(tableName).bulkWrite(requests);
public BulkWriteResult bulkWrite(List> requests,String tableName) {
BulkWriteResult write =Db().getCollection(tableName).bulkWrite(requests);
return write;
}
BulkWriteResult write = Db().getCollection(tableName).bulkWrite(requests);
难点在与如何拼接参数List> requests
例⼦:
DBObject queryObject = new BasicDBObject();
公乘queryObject.put("doctorId",doctorId);动物简笔画图片
DBObject fields = new BasicDBObject();
fields.put("_id",1);
十大动漫String tableName = PrefixNo().toLowerCa()+"-record";性格分析怎么写
List map = mongoService.String(),String(),Map.class,
tableName);
List> requests = new ArrayList>(); //创建参数集合杨子扬
时间的形状for(int i=0;i
Document queryDocument = new Document("_id",(i).get("_id")); //条件mode函数
蒜蓉辣椒Document updateDocument = new Document("$t",new ColName(),dataResult[i])); //更改信息
UpdateOneModel uom = new UpdateOneModel(queryDocument,updateDocument,new UpdateOptions().uprt(fal));
requests.add(uom);
}
BulkWriteResult bulkWriteResult = mongoService.bulkWrite(requests,tableName);