execute() public method

Execute the operation.
See also: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : InsertOneResult
$server MongoDB\Driver\Server
return Phalcon\Db\Adapter\MongoDB\InsertOneResult
Esempio n. 1
0
 /**
  * Inserts one document.
  *
  * @see InsertOne::__construct() for supported options
  * @see http://docs.mongodb.org/manual/reference/command/insert/
  *
  * @param array|object $document The document to insert
  * @param array        $options Command options
  *
  * @return InsertOneResult
  */
 public function insertOne($document, array $options = [])
 {
     if (!isset($options['writeConcern'])) {
         $options['writeConcern'] = $this->writeConcern;
     }
     $operation = new InsertOne($this->databaseName, $this->collectionName, $document, $options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }