Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database layer #3338

Merged
merged 81 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
42fb4ad
database response model
lohanidamodar May 30, 2022
f207849
database collection config
lohanidamodar May 30, 2022
cb366d1
new database scopes
lohanidamodar May 30, 2022
0562d92
database service update
lohanidamodar Jun 2, 2022
643a1eb
database execption codes
lohanidamodar Jun 2, 2022
1ea6646
remove read write permission from database model
lohanidamodar Jun 2, 2022
5f84a17
updating tests and fixing some bugs
lohanidamodar Jun 3, 2022
aa3c608
server side tests are now passing
lohanidamodar Jun 3, 2022
14a4f4e
databases api
lohanidamodar Jun 5, 2022
5b31c8f
tests for database endpoint
lohanidamodar Jun 5, 2022
4c62b40
Merge branch '0.15.x' of https://github.com/appwrite/appwrite into fe…
lohanidamodar Jun 5, 2022
a172c0a
composer update
lohanidamodar Jun 5, 2022
6494bfc
fix error
lohanidamodar Jun 5, 2022
b5300b9
formatting
lohanidamodar Jun 5, 2022
a507930
formatting fixes
lohanidamodar Jun 5, 2022
2d33a5d
get database test
lohanidamodar Jun 7, 2022
e201a0d
more updates to events and usage
lohanidamodar Jun 7, 2022
10cec65
more usage updates
lohanidamodar Jun 7, 2022
8d0a73a
fix delete type
lohanidamodar Jun 7, 2022
e77c017
fix test
lohanidamodar Jun 7, 2022
decca7d
delete database
lohanidamodar Jun 7, 2022
69eb386
more fixes
lohanidamodar Jun 7, 2022
c1dc15e
databaseId in attributes and indexes
lohanidamodar Jun 7, 2022
d4e6717
more fixes
lohanidamodar Jun 7, 2022
40e1a55
fix issues
lohanidamodar Jun 7, 2022
2f08b80
fix index subquery
lohanidamodar Jun 7, 2022
fac7534
fix console scope and index query
lohanidamodar Jun 7, 2022
2048417
updating tests as required
lohanidamodar Jun 7, 2022
e4f7a94
fix phpcs errors and warnings
lohanidamodar Jun 7, 2022
084ef0e
updates to review suggestions
lohanidamodar Jun 9, 2022
bcaacf0
UI progress
lohanidamodar Jun 9, 2022
68d4b8d
ui updates and cleaning up
lohanidamodar Jun 10, 2022
4bb6c1b
fix type
lohanidamodar Jun 10, 2022
cb60c4e
rework database events
lohanidamodar Jun 12, 2022
b0a89a9
update tests
lohanidamodar Jun 12, 2022
1a5eec8
update types
lohanidamodar Jun 12, 2022
aad1379
event generation fixed
lohanidamodar Jun 14, 2022
41215f8
events config updated
lohanidamodar Jun 14, 2022
a5a4c33
updating context to support multiple
lohanidamodar Jun 14, 2022
05fd983
realtime updates
lohanidamodar Jun 14, 2022
1f3eebe
Merge branch 'feat-database-layer' into fix-db-layer-realtime
lohanidamodar Jun 14, 2022
2f9a5e2
fix ids
lohanidamodar Jun 15, 2022
78942d0
Merge branch 'feat-database-layer' of https://github.com/appwrite/app…
lohanidamodar Jun 15, 2022
6bae1d9
Merge branch '0.15.x' into feat-database-layer
lohanidamodar Jun 15, 2022
e89aec8
update context
lohanidamodar Jun 15, 2022
18a4000
Merge branch 'feat-database-layer' of https://github.com/appwrite/app…
lohanidamodar Jun 15, 2022
269adb1
validator updates
lohanidamodar Jun 15, 2022
0f623dd
fix naming conflict
lohanidamodar Jun 15, 2022
103e0f8
fix tests
lohanidamodar Jun 15, 2022
27869a8
fix lint errors
lohanidamodar Jun 15, 2022
b43fa0d
fix wprler and realtime tests
lohanidamodar Jun 15, 2022
3c4a212
fix webhooks test
lohanidamodar Jun 15, 2022
8a0cbfc
fix event validator and other tests
lohanidamodar Jun 15, 2022
6b99657
formatting fixes
lohanidamodar Jun 15, 2022
a6d216b
Merge pull request #3364 from appwrite/feat-db-layer-ui
lohanidamodar Jun 19, 2022
0f6d0f1
removing leftover var_dumps
lohanidamodar Jun 19, 2022
f415f30
remove leftover comment
lohanidamodar Jun 19, 2022
8c14618
Merge pull request #3370 from appwrite/fix-db-layer-realtime
lohanidamodar Jun 19, 2022
2113e83
Merge branch '0.15.x' of https://github.com/appwrite/appwrite into fe…
lohanidamodar Jun 19, 2022
5f2276c
update usage params
lohanidamodar Jun 19, 2022
9a9da54
usage metrics updates
lohanidamodar Jun 19, 2022
b0deb14
update database usage
lohanidamodar Jun 19, 2022
08048f1
fix usage
lohanidamodar Jun 19, 2022
bd25d83
specs update
lohanidamodar Jun 19, 2022
e24367f
updates to usage
lohanidamodar Jun 19, 2022
1d1126d
fix UI and usage
lohanidamodar Jun 20, 2022
dc0a9c2
fix lints
lohanidamodar Jun 20, 2022
a7d3c5f
Merge pull request #3399 from appwrite/feat-db-layer-usage
lohanidamodar Jun 21, 2022
8f5eac0
Merge branch '0.15.x' of https://github.com/appwrite/appwrite into fe…
lohanidamodar Jun 21, 2022
8bb01ac
internal id fixes
lohanidamodar Jun 21, 2022
e1a1419
fixes for internal Id
lohanidamodar Jun 21, 2022
bd6583a
Merge pull request #3409 from appwrite/feat-database-layer-sync
lohanidamodar Jun 21, 2022
a34ce3d
renaming services and related files
lohanidamodar Jun 22, 2022
e6f360b
rename tests
lohanidamodar Jun 22, 2022
47f87cf
rename doc link
lohanidamodar Jun 22, 2022
abe0a80
rename readme
lohanidamodar Jun 22, 2022
2be37f5
fix test name
lohanidamodar Jun 22, 2022
6246913
Merge pull request #3416 from appwrite/fix-db-layer-renames
lohanidamodar Jun 22, 2022
2dd5502
Merge branch '0.15.x' of https://github.com/appwrite/appwrite into fe…
TorstenDittmann Jun 22, 2022
12394fd
Merge branch '0.15.x' of https://github.com/appwrite/appwrite into fe…
TorstenDittmann Jun 22, 2022
df7d50b
tests: fixes for 0.15.x sync
TorstenDittmann Jun 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
126 changes: 114 additions & 12 deletions app/config/collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,69 @@
*/

$collections = [
'collections' => [
'databases' => [
'$collection' => Database::METADATA,
'$id' => 'databases',
'name' => 'Databases',
'attributes' => [
[
'$id' => 'name',
'type' => Database::VAR_STRING,
'size' => 256,
'required' => true,
'signed' => true,
'array' => false,
'filters' => [],
],
[
'$id' => 'search',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
],
'indexes' => [
[
'$id' => '_fulltext_search',
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [],
'orders' => [],
],
],
],
'collections' => [
'$collection' => 'databases',
'$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 @@ -97,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 All @@ -114,7 +194,7 @@
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
Expand Down Expand Up @@ -238,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 @@ -252,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 All @@ -269,7 +371,7 @@
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
Expand Down Expand Up @@ -343,12 +445,12 @@
],
'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 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
2 changes: 2 additions & 0 deletions app/config/roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
'buckets.write',
'users.read',
'users.write',
'databases.read',
'databases.write',
'collections.read',
'collections.write',
'platforms.read',
Expand Down
6 changes: 6 additions & 0 deletions app/config/scopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
'teams.write' => [
'description' => 'Access to create, update, and delete your project\'s teams',
],
'databases.read' => [
'description' => 'Access to read your project\'s databases',
],
'databases.write' => [
'description' => 'Access to create, update, and delete your project\'s databases',
],
'collections.read' => [
'description' => 'Access to read your project\'s database collections',
],
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.