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
6 changes: 6 additions & 0 deletions docs/schema-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ Create a collection
$arangoClient->schema()->createCollection('users');
```

### createEdgeCollection(string $name, array $config = [], $waitForSyncReplication = null, $enforceReplicationFactor = null): stdClass
Create an Edge collection
```
$arangoClient->schema()->createEdgeCollection('relationships');
```

### updateCollection(string $name, array $config = []): stdClass
Update a collection
```
Expand Down
20 changes: 20 additions & 0 deletions src/Schema/ManagesCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ public function createCollection(
return $this->arangoClient->request('post', '/_api/collection', $options);
}

/**
* @param string $name
* @param array<mixed> $config
* @param int|bool|null $waitForSyncReplication
* @param int|bool|null $enforceReplicationFactor
* @return stdClass
*
* @throws ArangoException
*/
public function createEdgeCollection(
string $name,
array $config = [],
$waitForSyncReplication = null,
$enforceReplicationFactor = null
): stdClass {
$config['type'] = 3;

return $this->createCollection($name, $config, $waitForSyncReplication, $enforceReplicationFactor);
}

/**
* @param string $name
* @param array<mixed> $config
Expand Down
16 changes: 16 additions & 0 deletions tests/SchemaManagerCollectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,20 @@ public function testCreateCollectionWithOptions()
$this->assertTrue($result);
$this->assertFalse($this->schemaManager->hasCollection($collection));
}

public function testCreateEdgeCollection()
{
$collection = 'relationships';

if ($this->schemaManager->hasCollection($collection)) {
$this->schemaManager->deleteCollection($collection);
}

$result = $this->schemaManager->createEdgeCollection($collection);

$this->assertEquals($collection, $result->name);
$this->assertSame(3, $result->type);

$this->schemaManager->deleteCollection($collection);
}
}