Skip to content

Commit

Permalink
fix/total -이미지 삭제 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
glen15 committed Nov 3, 2021
1 parent 3ed388a commit 8f71d39
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions server/data/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ export async function validType(type) {

export async function editDoc(docId, data) {
const img = data.img; //[string, string]
await db.Docs_Images.destroy({
where: { docId },
});
if (!img.length) {

if (Array.isArray(img) && !img.length) {
await db.Docs_Images.destroy({
where: { docId },
});
if (data.event === "tennis") {
await db.Docs_Images.create({
docId,
Expand All @@ -193,7 +194,10 @@ export async function editDoc(docId, data) {
imgId: 58,
});
}
} else {
} else if (Array.isArray(img)) {
await db.Docs_Images.destroy({
where: { docId },
});
for (let i = 0; i < img.length; i++) {
const newImg = await db.Images.create({
link: img[i],
Expand Down Expand Up @@ -229,7 +233,6 @@ export async function editDoc(docId, data) {
const editedDoc = await db.Docs.findOne({
where: { id: docId },
}).catch((err) => console.log(err));

return editedDoc;
}

Expand Down

0 comments on commit 8f71d39

Please sign in to comment.