import { Injectable } from '@nestjs/common'; import Theatre from './theatre.entity'; import { firstValueFrom } from 'rxjs'; import { HttpService } from "@nestjs/axios"; import { Utility } from 'src/common/Utility'; @Injectable() export class TheatreService { constructor(private readonly httpService: HttpService) { } async findAll(): Promise<{ rows: Theatre[], count: number }> { return Theatre.findAndCountAll(); } async findByPk(id: number): Promise { return Theatre.findByPk(id); } findOne(theatre: Theatre): Promise { return Theatre.findOne({ where: theatre as any, }) } filter(theatre: Theatre): Promise { return Theatre.findAll({ where: theatre as any, }) } async remove(id: number): Promise { return Theatre.destroy({ where: { id: id } }); } async upsert(theatre: any, insertIfNotFound: boolean): Promise { if (theatre.id) { const existingTheatre = await this.findByPk(theatre.id); if (existingTheatre) { return Theatre.update(theatre, { where: { id: theatre.id } }); } } if (insertIfNotFound) { return Theatre.create(theatre as any) } } }