RORO = Receive an Object, Return an Object
❌ 안 좋은 예
findVenueParticipationByUserAndDate(
venueId: number,
userId: number,
scheduledDate: string,
)
⭕ RORO 적용 예
findVenueParticipationByUserAndDate({
venueId,
userId,
scheduledDate,
}: FindVenueParticipationByUserAndDateParams)
const participation =
await this.venueParticipationRepository.findVenueParticipationByUserAndDate(
venueId,
userId,
scheduledDate,
);
...
async findVenueParticipationByUserAndDate(
venueId: number,
userId: number,
scheduledDate: string,
) {
return await this.venueParticipationRepository.findOne({
where: {
venue: {
id: venueId,
},
user: {
id: userId,
},
scheduledDate: new Date(scheduledDate),
},
});
}
const participation =
await this.venueParticipationRepository.findVenueParticipationByUserAndDate({
venueId,
userId,
scheduledDate,
});
...
interface FindVenueParticipationByUserAndDateParams {
venueId: number;
userId: number;
scheduledDate: string;
}
async findVenueParticipationByUserAndDate({
venueId,
userId,
scheduledDate,
}: FindVenueParticipationByUserAndDateParams) {
return await this.venueParticipationRepository.findOne({
where: {
venue: {
id: venueId,
},
user: {
id: userId,
},
scheduledDate: new Date(scheduledDate),
},
});
}
| 목적 | 추천 네이밍 |
|---|---|
| Repository 입력 | ~Params |
| Service 입력 | ~Command |
| 조회 조건 | ~Query |
| 반환값 | ~Result |
SaveClusterCommentParams
FindClusterCommentsQuery
CreateClusterCommentResult
✔ 파라미터가 3개 이상일 경우
✔ 나중에 확장될 가능성 있을 경우
✔ TypeScript 사용 중일 경우