1
0
Fork 0
mirror of synced 2024-10-01 17:58:02 +13:00

Manually add the side to the attributes table

This commit is contained in:
Jake Barnby 2023-03-30 20:41:18 +13:00
parent ed54d9861f
commit 07d90aa4c4
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 8 additions and 0 deletions

View file

@ -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([

View file

@ -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',
])
;
}