#Only 1 outage

2 messages · Page 1 of 1 (latest)

sonic veldt
#

Hi @hollow lion

can you try this code

getAllMonitors(where?: Prisma.monitorsWhereInput, select?: Prisma.monitorsSelect): Promise<ReturnMonitor[]> {
    return this.prisma.monitors.findMany({
        include: {
            outages: {
                where: {
                    solved: null
                },
                take: 1, // Limit the number of outages to 1
            }
        }
    });
}
#

If i understand correctly, you don't want an array returned for outages. If that's the case then it's not possible because outages is defined to hold many values so an array would be the default type returnned.You would have to manually select the first one just like you are doing.