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:
@ -31,9 +31,7 @@ export class TimelineCalendarEventService {
|
||||
const calendarEventIds = await this.calendarEventRepository.find({
|
||||
where: {
|
||||
calendarEventParticipants: {
|
||||
person: {
|
||||
id: Any(personIds),
|
||||
},
|
||||
personId: Any(personIds),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
@ -81,8 +79,8 @@ export class TimelineCalendarEventService {
|
||||
const participants = event.calendarEventParticipants.map(
|
||||
(participant) => ({
|
||||
calendarEventId: event.id,
|
||||
personId: participant.person?.id ?? null,
|
||||
workspaceMemberId: participant.workspaceMember?.id ?? null,
|
||||
personId: participant.personId ?? null,
|
||||
workspaceMemberId: participant.workspaceMemberId ?? null,
|
||||
firstName:
|
||||
participant.person?.name?.firstName ||
|
||||
participant.workspaceMember?.name.firstName ||
|
||||
@ -135,9 +133,7 @@ export class TimelineCalendarEventService {
|
||||
): Promise<TimelineCalendarEventsWithTotal> {
|
||||
const personIds = await this.personRepository.find({
|
||||
where: {
|
||||
company: {
|
||||
id: companyId,
|
||||
},
|
||||
companyId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
Reference in New Issue
Block a user