コード例 #1
0
 public function testUnacknowledgedWriteConcern()
 {
     $documents = [['x' => 11]];
     $options = ['writeConcern' => new WriteConcern(0)];
     $operation = new InsertMany($this->getDatabaseName(), $this->getCollectionName(), $documents, $options);
     $result = $operation->execute($this->getPrimaryServer());
     $this->assertFalse($result->isAcknowledged());
     return $result;
 }
コード例 #2
0
 /**
  * Inserts multiple documents.
  *
  * @see InsertMany::__construct() for supported options
  * @see http://docs.mongodb.org/manual/reference/command/insert/
  * @param array[]|object[] $documents The documents to insert
  * @param array            $options   Command options
  * @return InsertManyResult
  */
 public function insertMany(array $documents, array $options = [])
 {
     if (!isset($options['writeConcern'])) {
         $options['writeConcern'] = $this->writeConcern;
     }
     $operation = new InsertMany($this->databaseName, $this->collectionName, $documents, $options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }