import { prismaClient as prisma } from '../../prismaClient' import { logger } from '../../utils/logger' export default async function createServiceProjectsForService({ data: serviceId, }: { data: string }) { try { // Will need to change that to not create a service project for EACH project. // When we will have geolocalization, we will create serviceProject for each project // That will be able to service this service const allProjects = await prisma.project.findMany({ where: {}, select: { id: true } }) await prisma.service.update({ where: { id: serviceId, }, data: { serviceProjects: { create: allProjects.map((project) => ({ project: { connect: { id: project.id }, }, })), }, }, }) } catch (error) { logger.error(error) } }