entity 연결 수정 및 코드정리
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { BaseModel } from 'src/common/entities/base.entity';
|
||||
import { FarmModel } from 'src/farm/entities/farm.entity';
|
||||
import { CowModel } from 'src/cow/entities/cow.entity';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
@@ -254,7 +254,10 @@ export class MptModel extends BaseModel {
|
||||
creatine: number;
|
||||
|
||||
// Relations
|
||||
@ManyToOne(() => FarmModel, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'fk_farm_no' })
|
||||
farm: FarmModel;
|
||||
@ManyToOne(() => CowModel, {
|
||||
onDelete: 'CASCADE',
|
||||
createForeignKeyConstraints: false
|
||||
})
|
||||
@JoinColumn({ name: 'cow_id', referencedColumnName: 'cowId' })
|
||||
cow: CowModel;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class MptService {
|
||||
async findByCowShortNo(cowShortNo: string): Promise<MptModel[]> {
|
||||
return this.mptRepository.find({
|
||||
where: { cowShortNo: cowShortNo, delDt: IsNull() },
|
||||
relations: ['farm'],
|
||||
relations: ['cow', 'cow.farm'],
|
||||
order: { testDt: 'DESC' },
|
||||
});
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export class MptService {
|
||||
async findByCowId(cowId: string): Promise<MptModel[]> {
|
||||
return this.mptRepository.find({
|
||||
where: { cowId: cowId, delDt: IsNull() },
|
||||
relations: ['farm'],
|
||||
relations: ['cow', 'cow.farm'],
|
||||
order: { testDt: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user