codestates / codestates/Bobpago
[πDev Log] λ°μ±ν / 2021.09.30
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
### μ€λμ μ΄λ»κ² νλ‘μ νΈμ κΈ°μ¬νλμ?
- λκΈ CRUD api μμ±
- λκΈ μ’μμ μΆκ° μμ api μμ±
- λ μνΌ μμ μ ν΄λΉ κ²μκΈμ μλ λκΈ S3 μ΄λ―Έμ§ μμ
```js
// νΉμ λ μνΌ μμ μ μμ μλ λκΈ S3 μ΄λ―Έμ§ μ 체 μμ
async deleteComments(recipeId: number) {
const comments = await this.commentRepository.find({ recipeId });
await Promise.all(
comments.map(async (comment) => {
if (comment.imageUrl !== '') {
return await this.deleteById(comment.id, 'comment');
}
}),
);
}
```
### μ€λμ νλ‘μ νΈμμ νλ μ μ 무μμΈκ°μ?
- λ μνΌλ₯Ό μμ ν λ λ μνΌ idλ₯Ό μ°Έμ‘° νκ³ μλ ν
μ΄λΈκΉμ§ κ°μ΄ μμ λ₯Ό μΌμΌν μ΄λ»κ² μμ ν΄μ£Όλμ§μ λν΄ κ³ λ―Όμ νλλΌ μκ°μ΄ μ€λκ±Έλ Έλ€.
- νλͺ©λ³λ‘ μ μ΄μ£ΌμΈμ.
```js
// 1. AWS S3μμ μ΄λ―Έμ§ κ°μ²΄ μμ
await this.imageService.deleteById(recipeId, 'recipe');
// 2. λ μνΌ_μ¬λ£ ν
μ΄λΈμμ λ μνΌ μμ΄λ κΈ°μ€μΌλ‘ μμ
await this.recipeIngredientRepository.delete({ recipeId });
// 3. λ μνΌ_μ΄λ―Έμ§ ν
μ΄λΈμμ λ μνΌ μμ΄λ κΈ°μ€μΌλ‘ μμ
await this.recipeImageRepository.delete({ recipeId });
// 4. λ μνΌ ν
μ΄λΈμμ μμ
await this.recipeRepository.delete({ id: recipeId });
```
μ΄λ°μμΌλ‘ μμ°¨μ μΌλ‘ λ μνΌ idλ₯Ό μ°Έμ‘°νκ³ μλ ν
μ΄λΈ μμλλ‘ μ§μλκ°λ©΄ μ€λ₯μμ΄ λ€ μ§μμ§λκ±Έ νμΈνλ€.
λ μ’μ λ°©λ²μ μλ¬ νΈλ€λ§μμ λ€λ£¨μλ€. ππ» [https://github.com/codestates/Bobpago/issues/120](https://github.com/codestates/Bobpago/issues/120)
### λ΄μΌμ νλ‘μ νΈμ κΈ°μ¬νκΈ° μν΄ λ¬΄μμ ν΄μΌ νλμ?
- [x] λ μνΌ λλ―Έλ°μ΄ν° μμ±
- [x] κ°μ’
μλ¬ λ° λ²κ·Έ λ°μμ μ½λ μμ
- [ ] λ°°ν¬ μλν ꡬν
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.