feat: manually implement joinColumn (#6022)
This PR introduce a new decorator named `@WorkspaceJoinColumn`, the goal
of this one is to manually declare the join columns inside the workspace
entities, so we don't have to rely on `ObjectRecord` type.
This decorator can be used that way:
```typescript
@WorkspaceRelation({
standardId: ACTIVITY_TARGET_STANDARD_FIELD_IDS.company,
type: RelationMetadataType.MANY_TO_ONE,
label: 'Company',
description: 'ActivityTarget company',
icon: 'IconBuildingSkyscraper',
inverseSideTarget: () => CompanyWorkspaceEntity,
inverseSideFieldKey: 'activityTargets',
})
@WorkspaceIsNullable()
company: Relation<CompanyWorkspaceEntity> | null;
// The argument is the name of the relation above
@WorkspaceJoinColumn('company')
companyId: string | null;
```
This commit is contained in:
@ -27,15 +27,11 @@ export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
const authorId = payload.id;
|
||||
|
||||
await this.attachmentRepository.delete({
|
||||
author: {
|
||||
id: authorId,
|
||||
},
|
||||
authorId,
|
||||
});
|
||||
|
||||
await this.commentRepository.delete({
|
||||
author: {
|
||||
id: authorId,
|
||||
},
|
||||
authorId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import { EntityManager } from 'typeorm';
|
||||
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
||||
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceMemberRepository {
|
||||
@ -15,7 +14,7 @@ export class WorkspaceMemberRepository {
|
||||
public async getByIds(
|
||||
userIds: string[],
|
||||
workspaceId: string,
|
||||
): Promise<ObjectRecord<WorkspaceMemberWorkspaceEntity>[]> {
|
||||
): Promise<WorkspaceMemberWorkspaceEntity[]> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
@ -45,7 +44,7 @@ export class WorkspaceMemberRepository {
|
||||
public async getByIdOrFail(
|
||||
userId: string,
|
||||
workspaceId: string,
|
||||
): Promise<ObjectRecord<WorkspaceMemberWorkspaceEntity>> {
|
||||
): Promise<WorkspaceMemberWorkspaceEntity> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
@ -68,7 +67,7 @@ export class WorkspaceMemberRepository {
|
||||
public async getAllByWorkspaceId(
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<ObjectRecord<WorkspaceMemberWorkspaceEntity>[]> {
|
||||
): Promise<WorkspaceMemberWorkspaceEntity[]> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user