yii\mongodb\Collection::batchInsert PHP Method

batchInsert() public method

Inserts several new rows into collection.
public batchInsert ( array $rows, array $options = [] ) : array
$rows array array of arrays or objects to be inserted.
$options array list of options in format: optionName => optionValue.
return array inserted data, each row will have "_id" key assigned to it.
    public function batchInsert($rows, $options = [])
    {
        $insertedIds = $this->database->createCommand()->batchInsert($this->name, $rows, $options);
        foreach ($rows as $key => $row) {
            $rows[$key]['_id'] = $insertedIds[$key];
        }
        return $rows;
    }