8b5f79ddbf
This PR is fixing some issues and adding enhancement in TwentyORM: - [x] Composite fields in nested relations are not formatted properly - [x] Passing operators like `Any` in `where` condition is breaking the query - [x] Ability to auto load workspace-entities based on a regex path I've also introduced an example of use for `CalendarEventService`: https://github.com/twentyhq/twenty/pull/5439/files#diff-3a7dffc0dea57345d10e70c648e911f98fe237248bcea124dafa9c8deb1db748R15
27 lines
764 B
TypeScript
27 lines
764 B
TypeScript
import { EntityManager, EntityTarget, ObjectLiteral } from 'typeorm';
|
|
|
|
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
|
|
|
export class WorkspaceEntityManager extends EntityManager {
|
|
override getRepository<Entity extends ObjectLiteral>(
|
|
target: EntityTarget<Entity>,
|
|
): WorkspaceRepository<Entity> {
|
|
// find already created repository instance and return it if found
|
|
const repoFromMap = this.repositories.get(target);
|
|
|
|
if (repoFromMap) {
|
|
return repoFromMap as WorkspaceRepository<Entity>;
|
|
}
|
|
|
|
const newRepository = new WorkspaceRepository<Entity>(
|
|
target,
|
|
this,
|
|
this.queryRunner,
|
|
);
|
|
|
|
this.repositories.set(target, newRepository);
|
|
|
|
return newRepository;
|
|
}
|
|
}
|