icons bug
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Entity, Index, Property, Collection, OneToMany } from '@mikro-orm/core';
|
import { Entity, Index, Property, Collection, OneToMany, Cascade } from '@mikro-orm/core';
|
||||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Icon } from './icon.entity';
|
import { Icon } from './icon.entity';
|
||||||
|
|
||||||
@@ -7,6 +7,9 @@ export class Group extends BaseEntity {
|
|||||||
@Property()
|
@Property()
|
||||||
name!: string;
|
name!: string;
|
||||||
|
|
||||||
@OneToMany(() => Icon, icon => icon.group)
|
@OneToMany(() => Icon, icon => icon.group,{
|
||||||
|
cascade: [Cascade.ALL],
|
||||||
|
orphanRemoval: true,
|
||||||
|
})
|
||||||
icons = new Collection<Icon>(this);
|
icons = new Collection<Icon>(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,12 +47,11 @@ export class GroupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: string): Promise<void> {
|
async remove(id: string): Promise<void> {
|
||||||
const group = await this.groupRepository.findOne({ id });
|
const group = await this.groupRepository.findOne({ id }, { populate: ['icons'] });
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw new NotFoundException(GroupMessage.NOT_FOUND);
|
throw new NotFoundException(GroupMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
group.deletedAt = new Date();
|
await this.em.removeAndFlush(group);
|
||||||
await this.em.persistAndFlush(group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findAllPublic(): Promise<Group[]> {
|
findAllPublic(): Promise<Group[]> {
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ export class IconService {
|
|||||||
if (!icon) {
|
if (!icon) {
|
||||||
throw new NotFoundException(IconMessage.NOT_FOUND);
|
throw new NotFoundException(IconMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
icon.deletedAt = new Date();
|
await this.em.removeAndFlush(icon);
|
||||||
await this.em.persistAndFlush(icon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user