jenssegers/MongoDB 这个包 insert 时候不支持输入参数?

刚才用到这个拓展包来插入一些数据进mongo,可是发现源码里并不支持携带参数

Jenssegers\Mongodb\Query\Builder;

public function insert(array $values)
{
  // Since every insert gets treated like a batch insert, we will have to detect
 // if the user is inserting a single document or an array of documents.\  $batch = true;

  foreach ($values as $value) {
  // As soon as we find a value that is not an array we assume the user is
 // inserting a single document.\  if (!is_array($value)) {
  $batch = false;
  break;
  }
 }
  if (!$batch) {
  $values = [$values];
  }

  // Batch insert
  $result = $this->collection->insertMany($values);

  return (1 == (int) $result->isAcknowledged());
}

是我不会用,还是真的不能有参数?

wanghan
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 5
liyu001989

可能得去 issue 里面看看,或者提 issue 问问作者

4年前 评论
wanghan

@liyu001989 刚才搜了搜,好像没人用到这个参数,我已经用php的mongoDB拓展写好代码了~以后给作者提个问,看看能不能加上insert参数

4年前 评论
liyu001989

你这个参数指的是什么

4年前 评论
wanghan

@liyu001989 ,在官网看到mongo4.0的文档,insert可以传入参数ordered,表示是否需要顺序插入,这个参数找不到在拓展包里哪里可以接收

4年前 评论
wanghan

刚才忘发链接了,不好意思https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/#db.collection.insertMany

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!