2021-04-08 08:39:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
2022-01-17 16:25:20 +00:00
|
|
|
use Utopia\Database\Document as DatabaseDocument;
|
2021-04-08 08:39:23 +00:00
|
|
|
|
|
|
|
|
class Document extends Any
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Get Name
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2021-04-08 08:39:23 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getName(): string
|
|
|
|
|
{
|
|
|
|
|
return 'Document';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-15 10:19:29 +00:00
|
|
|
* Get Type
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2021-04-08 08:39:23 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getType(): string
|
|
|
|
|
{
|
|
|
|
|
return Response::MODEL_DOCUMENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this
|
|
|
|
|
->addRule('$id', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Document ID.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
|
])
|
|
|
|
|
->addRule('$collection', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Collection ID.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5e5ea5c15117e',
|
|
|
|
|
])
|
2022-06-15 12:46:52 +00:00
|
|
|
->addRule('$createdAt', [
|
|
|
|
|
'type' => self::TYPE_INTEGER,
|
|
|
|
|
'description' => 'Document creation date in Unix timestamp.',
|
|
|
|
|
'default' => 0,
|
|
|
|
|
'example' => 1592981250,
|
|
|
|
|
])
|
|
|
|
|
->addRule('$updatedAt', [
|
|
|
|
|
'type' => self::TYPE_INTEGER,
|
|
|
|
|
'description' => 'Document update date in Unix timestamp.',
|
|
|
|
|
'default' => 0,
|
|
|
|
|
'example' => 1592981250,
|
|
|
|
|
])
|
2021-06-10 18:19:10 +00:00
|
|
|
->addRule('$read', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Document read permissions.',
|
|
|
|
|
'default' => '',
|
2021-06-30 15:10:45 +00:00
|
|
|
'example' => 'role:all',
|
2021-06-10 18:19:10 +00:00
|
|
|
'array' => true,
|
|
|
|
|
])
|
|
|
|
|
->addRule('$write', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Document write permissions.',
|
|
|
|
|
'default' => '',
|
2021-06-30 15:10:45 +00:00
|
|
|
'example' => 'user:608f9da25e7e1',
|
2021-06-10 18:19:10 +00:00
|
|
|
'array' => true,
|
|
|
|
|
])
|
|
|
|
|
;
|
2021-04-08 08:39:23 +00:00
|
|
|
}
|
2022-01-17 16:25:20 +00:00
|
|
|
|
|
|
|
|
public function filter(DatabaseDocument $document): DatabaseDocument
|
|
|
|
|
{
|
|
|
|
|
$document->removeAttribute('$internalId');
|
|
|
|
|
|
|
|
|
|
return $document;
|
|
|
|
|
}
|
2021-04-08 08:39:23 +00:00
|
|
|
}
|