diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 89e26abafd..69d01e9dc7 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -232,6 +232,7 @@ $utopia->get('/v1/database/collections/:collectionId/logs') $response->json($output); } ); + $utopia->put('/v1/database/collections/:collectionId') ->desc('Update Collection') ->label('scope', 'collections.write') @@ -416,6 +417,18 @@ $utopia->post('/v1/database/collections/:collectionId/documents') $data = $parentDocument->getArrayCopy(); } + /** + * Set default collection values + */ + foreach ($collection->getAttribute('rules') as $key => $rule) { + $key = (isset($rule['key'])) ? $rule['key'] : ''; + $default = (isset($rule['default'])) ? $rule['default'] : null; + + if(!isset($data[$key])) { + $data[$key] = $default; + } + } + try { $data = $projectDB->createDocument($data); } catch (AuthorizationException $exception) { diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index f4de51589c..4375dd4f12 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -68,16 +68,20 @@
documents found
- +
- + @@ -388,7 +392,7 @@ @@ -409,7 +413,7 @@ diff --git a/app/views/console/database/document.phtml b/app/views/console/database/document.phtml index 7271b8c2e6..1186bd0d5d 100644 --- a/app/views/console/database/document.phtml +++ b/app/views/console/database/document.phtml @@ -57,8 +57,8 @@
- -
+ +
@@ -70,7 +70,7 @@
-
+
-
  • -

    API

    - -
    -
    - -
    -
    -

    Response

    - -
    -
    +
  • +

    Activity

  • @@ -200,7 +186,7 @@ $list = [
    - + + + Linked Documents + Linked Document +