From 31c148ccd053be17c9fe86866a92b8760876f824 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:56:46 +0100 Subject: [PATCH] Create 021-server-defined-attributes.md --- 021-server-defined-attributes.md | 120 +++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 021-server-defined-attributes.md diff --git a/021-server-defined-attributes.md b/021-server-defined-attributes.md new file mode 100644 index 0000000..7b39cf8 --- /dev/null +++ b/021-server-defined-attributes.md @@ -0,0 +1,120 @@ +# Optional server-defined attributes + +* Creator: Khushboo Verma +* Relevant Issues: N/A + +- [RFC Template](#rfc-template) + - [Summary](#summary) + - [Resources](#resources) + - [Implementation](#implementation) + - [API Changes](#api-changes) + - [Workers / Commands](#workers--commands) + - [Supporting Libraries](#supporting-libraries) + - [Data Structures](#data-structures) + - [SDKs](#sdks) + - [Breaking Changes](#breaking-changes) + - [Documentation & Content](#documentation--content) + - [Reliability](#reliability) + - [Security](#security) + - [Scaling](#scaling) + - [Benchmarks](#benchmarks) + - [Tests (UI, Unit, E2E)](#tests-ui-unit-e2e) + - [Open Questions](#open-questions) + - [Future Possibilities](#future-possibilities) + +## Summary + +This RFC proposes the addition of optional server-defined attributes in all the project collections that can only be added by server and cannot be modified by the client. The user can add them to each collection through the API or console. Some useful sttributes can be `createdBy`, `updatedBy`, `ip` etc. + +## Resources + +NA + +## Implementation + + +#### Console Changes +We need to add an option in the `create attribute` settings dropdown to add a certain server-defined attribute from one of the existing options like `createdBy`. + +### API Changes + +We need 2 new API endpoints in `databases.php` for creating and deleting server-defined attributes. +- POST `/v1/databases/:databaseId/collections/:collectionId/attributes/server` +- DELETE `/v1/databases/:databaseId/collections/:collectionId/attributes/server/:key` + +We can allow users to create indexes for new attributes from the `createIndex` endpoint. + +We need to add a check in `createDocument` and `updateDocument` endpoints to populate the values of these attributes if they exist for client-side requests. + +### Workers / Commands + +No new workers are anticipated. + +### Supporting Libraries + +No new changes required in libraries. + +### Data Structures + +#### In appwrite/appwrite +The new attributes would add attributes to `attributes` collection in `$projectCollections` for each optional attribute. + +``` +$projectCollections = array_merge([ + 'attributes' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('attributes'), + 'name' => 'Attributes', + 'attributes' => [ + [ + '$id' => ID::custom('createdBy'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], +... +] +``` + +### SDKs + +SDKs will be updated to accommodate the changes in the API endpoints. + +### Breaking Changes + +No breaking changes are anticipated as this is an additive feature. + +### Documentation & Content + +The documentation will be updated to inform developers about the new endpoints and how to add these optional attributes in their collections. + +## Reliability + +### Security + + +### Scaling + +This feature will rely on existing infrastructure, so additional scaling measures are not anticipated. + +### Benchmarks + +No new benchmarks are required as existing infrastructure will support the feature. + +### Tests (UI, Unit, E2E) + +- End-to-end testing for each new endpoint and functionality. +- User Interface testing if a GUI component is added. + +## Open Questions + +N/A + +## Future Possibilities + +We could add more attributes like `device`, `geoLocation` etc.