So I have the following artisan command controller:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use MongoDB;
class TestCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'testcommand';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['test', 'data']);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 100);
$manager->executeBulkWrite('test.test', $bulk, $writeConcern);
}
}
When I try to run it with php artisan testcommand
(it's defined in Kernel.php) I get the following error:
[MongoDB\Driver\Exception\BulkWriteException]
BulkWrite error
That is very unhelpfully generic. Any idea what the problem is?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire