/** * {@inheritdoc} */ protected function performRollback($table, array $records) { $bulk = new BulkWrite(); foreach ($records as $record) { $id = $record['_id']; unset($record['_id']); $bulk->delete(array('_id' => $id)); } $this->conn->executeBulkWrite($this->getNamespace($table), $bulk); }
/** * Executes a bulk write to MongoDB, wrapping exceptions. * * @param \MongoDB\Driver\BulkWrite $bulk * @return \MongoDB\Driver\WriteResult the write result * @throws Swift_IoException if things go wrong */ protected function write(\MongoDB\Driver\BulkWrite $bulk) { try { return $this->manager->executeBulkWrite($this->collection, $bulk, $this->wc); } catch (\Exception $e) { throw new Swift_IoException("Could not update email sent on date", 0, $e); } }
/** * Write a message to the log. * * @param array $event Event data * @return void * @throws Exception\RuntimeException */ protected function doWrite(array $event) { if (null === $this->manager) { throw new Exception\RuntimeException('MongoDB\\Driver\\Manager must be defined'); } if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTimeInterface) { $millis = (int) floor((double) $event['timestamp']->format('U.u') * 1000); $event['timestamp'] = new UTCDateTime($millis); } $bulkWrite = new BulkWrite(); $bulkWrite->insert($event); $this->manager->executeBulkWrite($this->database, $bulkWrite, $this->writeConcern); }