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
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 5
liyu001989

你这个参数指的是什么

4年前 评论
wanghan

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

4年前 评论
wanghan

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

4年前 评论
liyu001989

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

4年前 评论
wanghan

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

4年前 评论

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