Manually add the side to the attributes table
This commit is contained in:
parent
ed54d9861f
commit
07d90aa4c4
2 changed files with 8 additions and 0 deletions
|
@ -101,6 +101,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
|
|||
}
|
||||
|
||||
if ($type === Database::VAR_RELATIONSHIP) {
|
||||
$options['side'] = Database::RELATION_SIDE_PARENT;
|
||||
$relatedCollection = $dbForProject->getDocument('database_' . $db->getInternalId(), $options['relatedCollection']);
|
||||
if ($relatedCollection->isEmpty()) {
|
||||
throw new Exception(Exception::COLLECTION_NOT_FOUND);
|
||||
|
@ -143,6 +144,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
|
|||
$twoWayKey = $options['twoWayKey'];
|
||||
$options['relatedCollection'] = $collection->getId();
|
||||
$options['twoWayKey'] = $key;
|
||||
$options['side'] = Database::RELATION_SIDE_CHILD;
|
||||
|
||||
try {
|
||||
$twoWayAttribute = new Document([
|
||||
|
|
|
@ -41,6 +41,12 @@ class AttributeRelationship extends Attribute
|
|||
'default' => 'restrict',
|
||||
'example' => 'restrict|cascade|setNull',
|
||||
])
|
||||
->addRule('side', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Whether this is the parent or child side of the relationship',
|
||||
'default' => '',
|
||||
'example' => 'parent|child',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue