做代码的网站,做网站需要知道哪些事情,专业的东莞网站设计,网站建设入门书籍mongodb3.4版本升级高版本后mongoTemplate.executeCommand的方式执行的语句报错#xff0c;如#xff1a;
Document document mongoTemplate.executeCommand(pipl)错误信息#xff1a;The cursor option is required 高版本的需要cursor选项参数#xff0c;官网这么写的如
Document document mongoTemplate.executeCommand(pipl)错误信息The cursor option is required 高版本的需要cursor选项参数官网这么写的 修改语句加入cursor cursor: {}, 里面也可以写参数不写应该是默认。 这时候返回的Document是一个cursor里面没有原来的result了。 里面是这些内容 我这里firstBatch里面就是对应之前的result结果。如果结果集有多个批次可能要遍历取下一批所有批次的总量才是之前的result。 为了兼容之前的代码做尽量少的改动把firstBatch取出来放到result里并且删除firstBatch后结果就与之前的一模一样了。
if (!CollectionUtils.isEmpty(document) document.containsKey(cursor) !document.containsKey(result)) {document.put(result,((Document)document.get(cursor)).get(firstBatch));document.remove(cursor);}
return document;