Skip to content
Snippets Groups Projects
Commit 91672e2e authored by Дмитрий Малюгин's avatar Дмитрий Малюгин :clock4:
Browse files

fix delete entity

parent e7f18e20
No related branches found
No related tags found
No related merge requests found
......@@ -117,6 +117,7 @@ class EntitiesService {
fs.unlink(body.image_path, (err) => {
if (err) throw err;
});
await PagesService.deletePageEntity(body.page_uuid, body.entity_uuid);
return {
entity_uuid: body.entity_uuid
};
......
......@@ -92,6 +92,22 @@ class PagesService {
}
});
}
async deletePageEntity(page_uuid: string, entity_uuid: string) {
const newState = await prisma.page.findFirst({
where: {
page_uuid: page_uuid
}
});
newState.page_entities = newState.page_entities.filter(
(entity) => entity.entity_uuid !== entity_uuid
);
await prisma.page.update({
data: { ...newState },
where: {
page_uuid: page_uuid
}
});
}
async deletePageBackground(page_uuid: string) {
const imagePath = path.join(path.resolve(), `/public/images/backgrounds/homeBackground.jpg`);
fs.unlink(imagePath, (err) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment