mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-30 03:43:02 +03:00
088d061b3e
### Overview This PR builds upon #5153, adding the ability to get a repository for custom objects. The `entitySchema` is now generated for both standard and custom objects based on metadata stored in the database instead of the decorated `WorkspaceEntity` in the code. This change ensures that standard objects with custom fields and relations can also support custom objects. ### Implementation Details #### Key Changes: - **Dynamic Schema Generation:** The `entitySchema` for standard and custom objects is now dynamically generated from the metadata stored in the database. This shift allows for greater flexibility and adaptability, particularly for standard objects with custom fields and relations. - **Custom Object Repository Retrieval:** A repository for a custom object can be retrieved using `TwentyORMManager` based on the object's name. Here's an example of how this can be achieved: ```typescript const repository = await this.twentyORMManager.getRepository('custom'); /* * `repository` variable will be typed as follows, ensuring that standard fields and relations are properly typed: * const repository: WorkspaceRepository<CustomWorkspaceEntity & { * [key: string]: any; * }> */ const res = await repository.find({}); ``` Fix #6179 --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Weiko <corentin@twenty.com>
15 lines
245 B
Plaintext
15 lines
245 B
Plaintext
|
|
{
|
|
"$schema": "https://json.schemastore.org/swcrc",
|
|
"sourceMaps": true,
|
|
"jsc": {
|
|
"parser": {
|
|
"syntax": "typescript",
|
|
"decorators": true,
|
|
"dynamicImport": true
|
|
},
|
|
"baseUrl": "./../../"
|
|
},
|
|
"minify": false
|
|
}
|