Get proper attribute models in collection document
This commit is contained in:
parent
b293c5dd65
commit
8d7b4a9c2d
|
@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
|
|||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Document;
|
||||
use stdClass;
|
||||
|
||||
class Collection extends Model
|
||||
|
@ -48,7 +49,21 @@ class Collection extends Model
|
|||
'description' => 'Collection attributes.',
|
||||
'default' => [],
|
||||
'example' => new stdClass,
|
||||
'array' => true
|
||||
'array' => true,
|
||||
'getNestedType' => function(Document $attribute) {
|
||||
return match($attribute->getAttribute('type')) {
|
||||
self::TYPE_BOOLEAN => Response::MODEL_ATTRIBUTE_BOOLEAN,
|
||||
self::TYPE_INTEGER => Response::MODEL_ATTRIBUTE_INTEGER,
|
||||
self::TYPE_FLOAT => Response::MODEL_ATTRIBUTE_FLOAT,
|
||||
self::TYPE_STRING => match($attribute->getAttribute('format')) {
|
||||
APP_DATABASE_ATTRIBUTE_EMAIL => Response::MODEL_ATTRIBUTE_EMAIL,
|
||||
APP_DATABASE_ATTRIBUTE_IP => Response::MODEL_ATTRIBUTE_IP,
|
||||
APP_DATABASE_ATTRIBUTE_URL => Response::MODEL_ATTRIBUTE_URL,
|
||||
default => Response::MODEL_ATTRIBUTE_STRING,
|
||||
},
|
||||
default => Response::MODEL_ATTRIBUTE,
|
||||
};
|
||||
},
|
||||
])
|
||||
->addRule('indexes', [
|
||||
'type' => Response::MODEL_INDEX,
|
||||
|
|
Loading…
Reference in a new issue