상품 등록할 때 위치정보 dto를 만들어 줘야함 => graphql (objectType, inputType 따로 만들어 줘야 함)
inputType만들 때 objectType를 상속 받는다.(omitType, pickType)
ex) class ... extends OmitType(..., ["", ""...], InputType) {}
createProductInput에 넣어준다.
constructor(
@InjectRepository(Product)
private readonly productRepository: Repository<Product>
@InjectRepository(productSaleslocaion)
private readonly productSaleslocaionRepository: Repository<productSaleslocaion>
){}
const { productSaleslocation, ...product } = createProductInput;
// 상품 주소 저장
const locationInfo = await this.productSaleslocationRepository.save({ ...productSaleslocation });
// 상품 저장
const result = await this.productRepository.save({
...product,
locationInfo // 전체를 프론트로 보내 줄 수 있다. 필요한 경우 id만 등록 해도 가능
});
return result;
await this.productRepository.find({ relation: ["productSaleslocation"], });
const { productSaleslocation, productCategoryId ...product, } = createProductInput;
const result = await this.productRepository.save({
...product,
productCategoryId,
locationInfo
});