方法:mongoTemplate.getDb().getCollection(tableName).bulkWrite(requests);
public BulkWriteResult bulkWrite(List<WriteModel> requests,String tableName) {
BulkWriteResult write = mongoTemplate.getDb().getCollection(tableName).bulkWrite(requests);
return write;
}
BulkWriteResult write = mongoTemplate.getDb().getCollection(tableName).bulkWrite(requests);
难点在与如何拼接参数List<WriteModel> requests
例子:
DBObject queryObject = new BasicDBObject();
queryObject.put("doctorId",doctorId);
DBObject fields = new BasicDBObject();
fields.put("_id",1);
String tableName = Constant.hospitalInfo.getPrefixNo().toLowerCase()+"-record";
List