-
Notifications
You must be signed in to change notification settings - Fork 24
Create 021-server-defined-attributes.md #60
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<!-- Describe the problem we want to solve and suggested solution in a few paragraphs --> | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's have exact list of all internal attributes we will have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would also be good to clarify exactly what the behavior of each would be. |
||
|
||
## Resources | ||
<!-- List all the resources used for writing this RFC --> | ||
NA | ||
|
||
## Implementation | ||
|
||
<!-- Write an overview to explain the suggested 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`. | ||
vermakhushboo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### API Changes | ||
<!-- Do we need new API endpoints? List and describe them and their API signatures --> | ||
We need 2 new API endpoints in `databases.php` for creating and deleting server-defined attributes. | ||
- POST `/v1/databases/:databaseId/collections/:collectionId/attributes/server` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets also have endpoint for listing them, so we don't need to hard-code then on Console. Its better to have config for it in Appwrite or library. |
||
- 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do updates at the utopia-php/database level as well so we might need to do it there instead. For example, updatedAt and createdAt are handled in utopia: https://github.com/utopia-php/database/blob/4199fe8f00f4e181c7782c4a6862845d591c1f03/src/Database/Database.php#L3050-L3051 |
||
|
||
### Workers / Commands | ||
<!-- Do we need new workers or commands for this feature? List and describe them and their API signatures --> | ||
No new workers are anticipated. | ||
|
||
### Supporting Libraries | ||
<!-- Do we need new libraries for this feature? Mention which, define the file structure, and different interfaces --> | ||
No new changes required in libraries. | ||
vermakhushboo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Data Structures | ||
<!-- Do we need new data structures for this feature? Describe and explain the new collections and attributes --> | ||
#### 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 | ||
<!-- Do we need to update our SDKs for this feature? Describe how --> | ||
SDKs will be updated to accommodate the changes in the API endpoints. | ||
|
||
### Breaking Changes | ||
<!-- Will this feature introduce any breaking changes? How can we achieve backward compatability --> | ||
No breaking changes are anticipated as this is an additive feature. | ||
vermakhushboo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Documentation & Content | ||
<!-- What documentation do we need to update or add for this feature? --> | ||
The documentation will be updated to inform developers about the new endpoints and how to add these optional attributes in their collections. | ||
|
||
## Reliability | ||
|
||
### Security | ||
<!-- How will we secure this feature? --> | ||
|
||
### Scaling | ||
<!-- How will we scale this feature? --> | ||
This feature will rely on existing infrastructure, so additional scaling measures are not anticipated. | ||
|
||
### Benchmarks | ||
<!-- How will we benchmark this feature? --> | ||
No new benchmarks are required as existing infrastructure will support the feature. | ||
|
||
### Tests (UI, Unit, E2E) | ||
<!-- How will we test this feature? --> | ||
- End-to-end testing for each new endpoint and functionality. | ||
- User Interface testing if a GUI component is added. | ||
|
||
## Open Questions | ||
<!-- List of things we need to figure out or farther discuss --> | ||
N/A | ||
vermakhushboo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Future Possibilities | ||
<!-- List of things we could do in the future to extend or take advatage due to this new feature --> | ||
We could add more attributes like `device`, `geoLocation` etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.