From 434378bdda702eafaf2bb0d7b91c5f0e17ec223c Mon Sep 17 00:00:00 2001 From: eldadfux Date: Thu, 15 Aug 2019 01:01:27 +0300 Subject: [PATCH] Updated collections timestamps and formats --- app/config/collections.php | 30 ++++++++++++++++++++++++------ app/controllers/database.php | 3 +++ app/controllers/projects.php | 6 +++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 01d6efd50b..796dc48f72 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -74,6 +74,24 @@ return [ 'required' => true, 'array' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => 'numeric', + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Updated', + 'key' => 'dateUpdated', + 'type' => 'numeric', + 'default' => 0, + 'required' => false, + 'array' => false, + ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Structure', @@ -1242,19 +1260,19 @@ return [ ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Created', - 'key' => 'created', + 'label' => 'Date Created', + 'key' => 'dateCreated', 'type' => 'numeric', - 'default' => '', + 'default' => 0, 'required' => false, 'array' => false, ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Updated', - 'key' => 'updated', + 'label' => 'Date Updated', + 'key' => 'dateUpdated', 'type' => 'numeric', - 'default' => '', + 'default' => 0, 'required' => false, 'array' => false, ], diff --git a/app/controllers/database.php b/app/controllers/database.php index 6f483b3667..eefee89540 100644 --- a/app/controllers/database.php +++ b/app/controllers/database.php @@ -141,6 +141,8 @@ $utopia->post('/v1/database') $data = $projectDB->createDocument([ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, 'name' => $name, + 'dateCreated' => time(), + 'dateUpdated' => time(), 'structure' => true, '$permissions' => [ 'read' => $read, @@ -204,6 +206,7 @@ $utopia->put('/v1/database/:collectionId') $collection = $projectDB->updateDocument(array_merge($collection->getArrayCopy(), [ 'name' => $name, 'structure' => true, + 'dateUpdated' => time(), '$permissions' => [ 'read' => $read, 'write' => $write, diff --git a/app/controllers/projects.php b/app/controllers/projects.php index 41a7d48b81..8987aac869 100644 --- a/app/controllers/projects.php +++ b/app/controllers/projects.php @@ -1107,8 +1107,8 @@ $utopia->post('/v1/projects/:projectId/platforms') 'key' => $key, 'store' => $store, 'url' => $url, - 'created' => time(), - 'updated' => time(), + 'dateCreated' => time(), + 'dateUpdated' => time(), ]); if(false === $platform) { @@ -1158,7 +1158,7 @@ $utopia->put('/v1/projects/:projectId/platforms/:platformId') $platform ->setAttribute('name', $name) - ->setAttribute('updated', time()) + ->setAttribute('dateUpdated', time()) ->setAttribute('key', $key) ->setAttribute('store', $store) ->setAttribute('url', $url)