官网定义原生执行操作MongoDB的文档如下
execute ($collection, $bulk)
collection:表示当前查询的集合
bulk:是一个\MongoDB\Driver\BulkWrite对象
以下是测试代码
$data = [
'name' => 'Tome',
'age' => 20
];
$bulk = new \MongoDB\Driver\BulkWrite();
$bulk->insert($data);
Db::execute('demo', $bulk);
返回错误信息:
message: think\db\connector\Mongo::execute(): Argument #1 ($bulk) must be of type MongoDB\Driver\BulkWrite, string given
file: vendor/topthink/think-orm/src/db/connector/Mongo.php
line: 316