/** * 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); }