/** * List the indices on a collection. * @param string $collection The name of the collection. * @param boolean $includeInfo Whether we want information on each index. If false, only an array of index ids will be returned. * @throws CollectionManagerException * @return array */ public function listIndices($collection, $includeInfo = false) { if (isset($this->_indexInfoCache[$collection])) { return $this->_indexInfoCache[$collection]; } try { $result = $this->_toolbox->getCollectionHandler()->getIndexes($collection); $this->_indexInfoCache[$collection] = $result['identifiers']; if ($includeInfo) { return $this->_indexInfoCache[$collection]; } else { return array_keys($this->_indexInfoCache[$collection]); } } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new CollectionManagerException($normalised['message'], $normalised['code']); } }
/** * Returns a random document from a collection. * @param string $type The collection we want to get the document from. * @throws FinderException * @return AModel */ public function any($type) { if ($this->_toolbox->getTransactionManager()->hasTransaction()) { $this->_toolbox->getTransactionManager()->addReadCollection($type); $this->_toolbox->getTransactionManager()->addCommand("db.{$type}.any();", "Finder:any", null, false, array('type' => $type)); } else { try { $result = $this->_toolbox->getCollectionHandler()->any($type); if (!$result) { return null; } $converted = $this->convertToPods($type, array($result)); return reset($converted); } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new FinderException($normalised['message'], $normalised['code']); } } }
/** * @covers Paradox\Toolbox::getCollectionHandler */ public function testGetCollectionHandler() { $collectionHandler = $this->toolbox->getCollectionHandler(); $this->assertInstanceOf('triagens\\ArangoDb\\CollectionHandler', $collectionHandler, 'getCollectionHandler() did not return a triagens\\ArangoDb\\CollectionHandler'); }