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