/** * Create a skip-list index on a collection. * @param string $collection The name of the collection. * @param array|string $fields The array of fields or a string representing 1 field. * @param bool $unique Whether the index is unique or not. * @link http://www.arangodb.org/manuals/current/IndexSkiplistHttp.html * @throws CollectionManagerException * @return int Id of the index created. */ public function createSkipListIndex($collection, $fields, $unique = null) { if (!is_array($fields)) { $fields = array($fields); } try { $result = $this->_toolbox->getCollectionHandler()->createSkipListIndex($collection, $fields, $unique); return $this->_toolbox->parseIdForKey($result['id']); } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new CollectionManagerException($normalised['message'], $normalised['code']); } }
/** * Given the id in ArangoDB format (mycollection/123456) parse it and return the key (123456). * @param string $id * @return string */ protected function parseIdForKey($id) { return $this->_toolbox->parseIdForKey($id); }
/** * @covers Paradox\Toolbox::parseIdForKey */ public function testParseIdForKey() { $key = $this->toolbox->parseIdForKey('mycollection/123456'); $this->assertEquals('123456', $key, "The parsed key does not match"); }