diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 4b51a05087..c7c9c49d8e 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -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([ diff --git a/src/Appwrite/Utopia/Response/Model/AttributeRelationship.php b/src/Appwrite/Utopia/Response/Model/AttributeRelationship.php index d743eccf83..7d1006f418 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeRelationship.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeRelationship.php @@ -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', + ]) ; }