Skip to content

Commit

Permalink
Database layer (#3338)
Browse files Browse the repository at this point in the history
* database response model

* database collection config

* new database scopes

* database service update

* database execption codes

* remove read write permission from database model

* updating tests and fixing some bugs

* server side tests are now passing

* databases api

* tests for database endpoint

* composer update

* fix error

* formatting

* formatting fixes

* get database test

* more updates to events and usage

* more usage updates

* fix delete type

* fix test

* delete database

* more fixes

* databaseId in attributes and indexes

* more fixes

* fix issues

* fix index subquery

* fix console scope and index query

* updating tests as required

* fix phpcs errors and warnings

* updates to review suggestions

* UI progress

* ui updates and cleaning up

* fix type

* rework database events

* update tests

* update types

* event generation fixed

* events config updated

* updating context to support multiple

* realtime updates

* fix ids

* update context

* validator updates

* fix naming conflict

* fix tests

* fix lint errors

* fix wprler and realtime tests

* fix webhooks test

* fix event validator and other tests

* formatting fixes

* removing leftover var_dumps

* remove leftover comment

* update usage params

* usage metrics updates

* update database usage

* fix usage

* specs update

* updates to usage

* fix UI and usage

* fix lints

* internal id fixes

* fixes for internal Id

* renaming services and related files

* rename tests

* rename doc link

* rename readme

* fix test name

* tests: fixes for 0.15.x sync

Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
  • Loading branch information
2 people authored and Vincent (Wen Yu) Ge committed Jun 22, 2022
1 parent b9d021a commit 4419fd2
Show file tree
Hide file tree
Showing 82 changed files with 2,317 additions and 1,314 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ RUN chmod +x /usr/local/bin/doctor && \
chmod +x /usr/local/bin/vars && \
chmod +x /usr/local/bin/worker-audits && \
chmod +x /usr/local/bin/worker-certificates && \
chmod +x /usr/local/bin/worker-database && \
chmod +x /usr/local/bin/worker-databases && \
chmod +x /usr/local/bin/worker-deletes && \
chmod +x /usr/local/bin/worker-functions && \
chmod +x /usr/local/bin/worker-builds && \
Expand Down
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ docker run -it --rm ,
* [**帐户**](https://appwrite.io/docs/client/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session,登录设备,登录方法和查看相关记录。
* [**用户**](https://appwrite.io/docs/server/users) - 在以管理员模式登录时管理和列出所有用户。
* [**团队**](https://appwrite.io/docs/client/teams) - 管理用户分组。邀请成员,管理团队中的用户权限和用户角色。
* [**数据库**](https://appwrite.io/docs/client/database) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。
* [**数据库**](https://appwrite.io/docs/client/databases) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。
* [**贮存**](https://appwrite.io/docs/client/storage) - 管理文件的阅读、创建、删除和预览。设置文件的预览来满足程序的个性化需求。所有文件都由 ClamAV 扫描并安全存储和加密。
* [**云函数**](https://appwrite.io/docs/server/functions) - 在安全,隔离的环境中运行自定义代码。这些代码可以被事件,CRON,或者手动操作触发。
* [**语言适配**](https://appwrite.io/docs/client/locale) - 根据用户所在的的国家和地区做出合适的语言适配。
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Getting started with Appwrite is as easy as creating a new project, choosing you
* [**Account**](https://appwrite.io/docs/client/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs.
* [**Users**](https://appwrite.io/docs/server/users) - Manage and list all project users when in admin mode.
* [**Teams**](https://appwrite.io/docs/client/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team.
* [**Database**](https://appwrite.io/docs/client/database) - Manage database collections and documents. Read, create, update, and delete documents and filter lists of document collections using advanced filters.
* [**Databases**](https://appwrite.io/docs/client/databases) - Manage databases, collections and documents. Read, create, update, and delete documents and filter lists of document collections using advanced filters.
* [**Storage**](https://appwrite.io/docs/client/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way.
* [**Functions**](https://appwrite.io/docs/server/functions) - Customize your Appwrite server by executing your custom code in a secure, isolated environment. You can trigger your code on any Appwrite system event, manually or using a CRON schedule.
* [**Locale**](https://appwrite.io/docs/client/locale) - Track your user's location, and manage your app locale-based data.
Expand Down
82 changes: 74 additions & 8 deletions app/config/collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@
'$id' => 'collections',
'name' => 'Collections',
'attributes' => [
[
'$id' => 'databaseInternalId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'databaseId',
'type' => Database::VAR_STRING,
'signed' => true,
'size' => Database::LENGTH_KEY,
'format' => '',
'filters' => [],
'required' => true,
'default' => null,
'array' => false,
],
[
'$id' => 'name',
'type' => Database::VAR_STRING,
Expand Down Expand Up @@ -133,6 +155,28 @@
'$id' => 'attributes',
'name' => 'Attributes',
'attributes' => [
[
'$id' => 'databaseInternalId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'databaseId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => false,
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'collectionInternalId',
'type' => Database::VAR_STRING,
Expand Down Expand Up @@ -274,11 +318,11 @@
],
'indexes' => [
[
'$id' => '_key_collection',
'$id' => '_key_db_collection',
'type' => Database::INDEX_KEY,
'attributes' => ['collectionInternalId'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
'attributes' => ['databaseInternalId', 'collectionInternalId'],
'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC, Database::ORDER_ASC],
],
],
],
Expand All @@ -288,6 +332,28 @@
'$id' => 'indexes',
'name' => 'Indexes',
'attributes' => [
[
'$id' => 'databaseInternalId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'databaseId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => false,
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'collectionInternalId',
'type' => Database::VAR_STRING,
Expand Down Expand Up @@ -381,10 +447,10 @@
[
'$id' => '_key_db_collection',
'type' => Database::INDEX_KEY,
'attributes' => ['collectionInternalId'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
]
'attributes' => ['databaseInternalId', 'collectionInternalId'],
'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC, Database::ORDER_ASC],
],
],
],

Expand Down
80 changes: 47 additions & 33 deletions app/config/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,68 @@
],
]
],
'collections' => [
'$model' => Response::MODEL_COLLECTION,
'databases' => [
'$model' => Response::MODEL_DATABASE,
'$resource' => true,
'$description' => 'This event triggers on any collection event.',
'documents' => [
'$model' => Response::MODEL_DOCUMENT,
'$description' => 'This event triggers on any database event.',
'collections' => [
'$model' => Response::MODEL_COLLECTION,
'$resource' => true,
'$description' => 'This event triggers on any documents event.',
'create' => [
'$description' => 'This event triggers when a document is created.',
],
'delete' => [
'$description' => 'This event triggers when a document is deleted.'
'$description' => 'This event triggers on any collection event.',
'documents' => [
'$model' => Response::MODEL_DOCUMENT,
'$resource' => true,
'$description' => 'This event triggers on any documents event.',
'create' => [
'$description' => 'This event triggers when a document is created.',
],
'delete' => [
'$description' => 'This event triggers when a document is deleted.'
],
'update' => [
'$description' => 'This event triggers when a document is updated.'
],
],
'indexes' => [
'$model' => Response::MODEL_INDEX,
'$resource' => true,
'$description' => 'This event triggers on any indexes event.',
'create' => [
'$description' => 'This event triggers when an index is created.',
],
'delete' => [
'$description' => 'This event triggers when an index is deleted.'
]
],
'update' => [
'$description' => 'This event triggers when a document is updated.'
'attributes' => [
'$model' => Response::MODEL_ATTRIBUTE,
'$resource' => true,
'$description' => 'This event triggers on any attributes event.',
'create' => [
'$description' => 'This event triggers when an attribute is created.',
],
'delete' => [
'$description' => 'This event triggers when an attribute is deleted.'
]
],
],
'indexes' => [
'$model' => Response::MODEL_INDEX,
'$resource' => true,
'$description' => 'This event triggers on any indexes event.',
'create' => [
'$description' => 'This event triggers when an index is created.',
'$description' => 'This event triggers when a collection is created.'
],
'delete' => [
'$description' => 'This event triggers when an index is deleted.'
]
],
'attributes' => [
'$model' => Response::MODEL_ATTRIBUTE,
'$resource' => true,
'$description' => 'This event triggers on any attributes event.',
'create' => [
'$description' => 'This event triggers when an attribute is created.',
'$description' => 'This event triggers when a collection is deleted.',
],
'delete' => [
'$description' => 'This event triggers when an attribute is deleted.'
'update' => [
'$description' => 'This event triggers when a collection is updated.',
]
],
'create' => [
'$description' => 'This event triggers when a collection is created.'
'$description' => 'This event triggers when a database is created.'
],
'delete' => [
'$description' => 'This event triggers when a collection is deleted.',
'$description' => 'This event triggers when a database is deleted.',
],
'update' => [
'$description' => 'This event triggers when a collection is updated.',
'$description' => 'This event triggers when a database is updated.',
]
],
'buckets' => [
Expand Down
16 changes: 8 additions & 8 deletions app/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@
'optional' => true,
'icon' => '/images/services/avatars.png',
],
'database' => [
'key' => 'database',
'name' => 'Database',
'subtitle' => 'The Database service allows you to create structured collections of documents, query and filter lists of documents',
'description' => '/docs/services/database.md',
'controller' => 'api/database.php',
'databases' => [
'key' => 'databases',
'name' => 'Databases',
'subtitle' => 'The Databases service allows you to create structured collections of documents, query and filter lists of documents',
'description' => '/docs/services/databases.md',
'controller' => 'api/databases.php',
'sdk' => true,
'docs' => true,
'docsUrl' => 'https://appwrite.io/docs/client/database',
'docsUrl' => 'https://appwrite.io/docs/client/databases',
'tests' => false,
'optional' => true,
'icon' => '/images/services/database.png',
'icon' => '/images/services/databases.png',
],
'locale' => [
'key' => 'locale',
Expand Down
2 changes: 1 addition & 1 deletion app/config/specs/open-api3-0.15.x-client.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/open-api3-0.15.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/open-api3-0.15.x-server.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/open-api3-latest-client.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/open-api3-latest-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/open-api3-latest-server.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-0.15.x-client.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-0.15.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-0.15.x-server.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-latest-client.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-latest-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config/specs/swagger2-latest-server.json

Large diffs are not rendered by default.

0 comments on commit 4419fd2

Please sign in to comment.