execute() public method

Execute the operation.
See also: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : InsertManyResult
$server MongoDB\Driver\Server
return Phalcon\Db\Adapter\MongoDB\InsertManyResult
Exemplo n.º 1
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);
 }