remove relation between request and invoice
This commit is contained in:
@@ -13,7 +13,6 @@ import { User } from '../../user/entities/user.entity';
|
||||
import { ulid } from 'ulid';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
import { RequestItem } from './request-item.entity';
|
||||
import { Invoice } from 'src/modules/invoice/entities/invoice.entity';
|
||||
|
||||
@Entity({ tableName: 'requests' })
|
||||
@Index({ properties: ['user'] })
|
||||
@@ -27,9 +26,6 @@ export class Request extends BaseEntity {
|
||||
@ManyToOne(() => User)
|
||||
user!: User;
|
||||
|
||||
@OneToMany(()=>Invoice, invoice => invoice.request)
|
||||
invoices = new Collection<Invoice>(this);
|
||||
|
||||
@OneToMany(() => RequestItem, item => item.request, {
|
||||
cascade: [Cascade.ALL],
|
||||
orphanRemoval: true,
|
||||
|
||||
@@ -65,7 +65,7 @@ export class RequestRepository extends EntityRepository<Request> {
|
||||
limit,
|
||||
offset,
|
||||
orderBy: { [orderBy]: order.toLowerCase() as 'asc' | 'desc' },
|
||||
populate: ['items', 'items.product', 'user','invoices'],
|
||||
populate: ['items', 'items.product', 'user'],
|
||||
});
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
@@ -221,7 +221,7 @@ export class RequestService {
|
||||
|
||||
private async hardDeleteRequest(id: string, em: EntityManager) {
|
||||
await this.chatService.deleteChatsByRefId(id, em);
|
||||
await em.nativeUpdate(Invoice, { request: { id } }, { request: null });
|
||||
await em.nativeUpdate(Invoice, { requestId: id }, { requestId: null });
|
||||
await em.nativeDelete(RequestItem, { request: { id } });
|
||||
await em.nativeDelete(Request, { id });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user