|
| 1 | +# Schema manager - Graphs |
| 2 | +You can use the schema manager to perform CRUD actions on named graphs. |
| 3 | + |
| 4 | +## Graph functions |
| 5 | +The schema manager supports the following graph functions: |
| 6 | + |
| 7 | +### public function createGraph(string $name, array $config = [], $waitForSync = false) |
| 8 | +``` |
| 9 | +$arangoClient->schema()->createGraph( |
| 10 | + 'relations', |
| 11 | + [ |
| 12 | + 'edgeDefinitions' => [ |
| 13 | + [ |
| 14 | + 'collection' => 'children', |
| 15 | + 'from' => ['characters'], |
| 16 | + 'to' => ['characters'] |
| 17 | + ] |
| 18 | + ], |
| 19 | + 'orphanCollections' => [ |
| 20 | + 'orphanVertices' |
| 21 | + ], |
| 22 | + ], |
| 23 | + true |
| 24 | +); |
| 25 | +``` |
| 26 | + |
| 27 | +### getGraph(string $name): array |
| 28 | +``` |
| 29 | +$arangoClient->schema()->getGraphs('relations'); |
| 30 | +``` |
| 31 | + |
| 32 | +### getGraphs(): array |
| 33 | +``` |
| 34 | +$arangoClient->schema()->getGraphs(); |
| 35 | +``` |
| 36 | + |
| 37 | +### hasGraph(string $name): bool |
| 38 | +``` |
| 39 | +$arangoClient->schema()->hasGraph('relations'); |
| 40 | +``` |
| 41 | + |
| 42 | +### deleteGraph(string $name): bool |
| 43 | +``` |
| 44 | +$arangoClient->schema()->deleteGraph('locations'); |
| 45 | +``` |
| 46 | + |
| 47 | +### getGraphVertices(string $name): array |
| 48 | +``` |
| 49 | +$arangoClient->schema()->getGraphVertices('relations'); |
| 50 | +``` |
| 51 | + |
| 52 | +### addGraphVertex(string $name, string $vertex): array |
| 53 | +``` |
| 54 | +$arangoClient->schema()->addGraphVertex('relations', 'houses'); |
| 55 | +``` |
| 56 | + |
| 57 | +### removeGraphVertex(string $name, string $vertex, bool $dropCollection = false): array |
| 58 | +``` |
| 59 | +$arangoClient->schema()->removeGraphVertex('relations', 'houses', true); |
| 60 | +``` |
| 61 | + |
| 62 | +### getGraphEdges(string $name): array |
| 63 | +``` |
| 64 | +$arangoClient->schema()->deleteGraph('locations'); |
| 65 | +``` |
| 66 | + |
| 67 | +### addGraphEdge(string $name, array $edgeDefinition): array |
| 68 | +``` |
| 69 | +$arangoClient->schema()->addGraphEdge( |
| 70 | + 'relations', |
| 71 | + [ |
| 72 | + 'collection' => 'vassals', |
| 73 | + 'from' => ['characters'], |
| 74 | + 'to' => ['houses'] |
| 75 | + ] |
| 76 | +); |
| 77 | +``` |
| 78 | + |
| 79 | +### replaceGraphEdge(string $name, string $edge, array $edgeDefinition, bool $dropCollection = false, bool $waitForSync = false): array |
| 80 | +``` |
| 81 | +$arangoClient->schema()->createGraph( |
| 82 | + 'relations', |
| 83 | + [ |
| 84 | + 'edgeDefinitions' => [ |
| 85 | + [ |
| 86 | + 'collection' => 'children', |
| 87 | + 'from' => ['characters'], |
| 88 | + 'to' => ['characters'] |
| 89 | + ] |
| 90 | + ] |
| 91 | + ] |
| 92 | +); |
| 93 | +``` |
| 94 | + |
| 95 | +### removeGraphEdge(string $name, string $edge, bool $dropCollection = true, bool $waitForSync = false): array |
| 96 | +``` |
| 97 | +$arangoClient->schema()->removeGraphEdge( |
| 98 | + 'relations', |
| 99 | + 'children', |
| 100 | + true, |
| 101 | + true |
| 102 | +); |
| 103 | +``` |
| 104 | + |
0 commit comments