-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added documentation for guidelines for creating entity defnitions
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Specifying database entity defnitions for usage with the server | ||
|
||
Please adhere to the following guidelines when creating TypeORM entity defnitions: | ||
|
||
**Defaults**: | ||
|
||
- no defaults in entity definitions; set defaults through business logic | ||
- no defaults to the class fields | ||
|
||
**Relations**: | ||
|
||
- relations that are not eager need to be defined as optional, since they need to be loaded explicitly | ||
|
||
**Lengths**: | ||
|
||
- always define length with constants | ||
- stick to the existing length constants OR in the rear case - create one if nothing fits | ||
|
||
| data | what to use | | ||
| ------------------- | ---------------------- | | ||
| Alkemio identifiers | `char(UUID_LENGTH)` | | ||
| enums | `varchar(ENUM_LENGTH)` | | ||
| short text | `varchar(your length)` | | ||
| long text | `text` | | ||
| URI, URL | `varchar(URI_LENGHT)` | | ||
|
||
## Usage | ||
|
||
- generate a domain change migration via `migration:generate` |