Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/schema-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ $arangoClient->schema()->hasGraph('relations');
$arangoClient->schema()->deleteGraph('locations');
```

### deleteAllGraphs(): bool
This method deletes all named graphs available on the current database.

```
$arangoClient->schema()->deleteAllGraphs();
```

### getGraphVertices(string $name): array
```
$arangoClient->schema()->getGraphVertices('relations');
Expand Down
14 changes: 14 additions & 0 deletions src/Schema/ManagesGraphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ public function deleteGraph(string $name): bool
return (bool) $this->arangoClient->request('delete', $uri);
}

/**
* @throws ArangoException
*/
public function deleteAllGraphs(): bool
{
$graphs = $this->getGraphs();

foreach ($graphs as $graph) {
$this->deleteGraph($graph->name);
}

return true;
}

/**
* @see https://www.arangodb.com/docs/stable/http/gharial-management.html#list-vertex-collections
*
Expand Down
15 changes: 15 additions & 0 deletions tests/SchemaManagerGraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,18 @@
$this->schemaManager->deleteCollection('characters');
$this->schemaManager->deleteCollection('vassals');
});

test('deleteAllGraphs', function () {
$result = $this->schemaManager->createGraph('graph1', [], true);
$result = $this->schemaManager->createGraph('graph2', [], true);

$createdGraphs = $this->schemaManager->getGraphs();

$result = $this->schemaManager->deleteAllGraphs();

$finalGraphs = $this->schemaManager->getGraphs();

expect($result)->toBeTrue();
expect(count($createdGraphs))->toBe(2);
expect(count($finalGraphs))->toBe(0);
})->only();