Fix client count

This commit is contained in:
Douglas Barone 2022-04-04 15:27:56 -04:00
parent 0b7b8b4c69
commit bf93c9fc43
3 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,13 @@
import prisma from "../prisma";
export const AccessPoint = {
updatedAt: parent => parent.updatedAt?.toISOString()
updatedAt: parent => parent.updatedAt?.toISOString(),
clients: parent => prisma.wifiDevice.count({
where: {
status: 'ONLINE',
accessPoint: {
id: parent.id
}
}
})
}

View File

@ -1,7 +1,7 @@
import prisma from '../../prisma'
export async function accessPoint(parent, { id }, context, info) {
return prisma.accessPoint.findUnique({
const ap = prisma.accessPoint.findUnique({
where: { id: parseInt(id) },
include: {
wifiDevices: {
@ -11,4 +11,6 @@ export async function accessPoint(parent, { id }, context, info) {
}
}
})
console.log(ap);
return ap
}

View File

@ -6,7 +6,11 @@ export async function accessPoints() {
hostname: 'asc'
},
include: {
wifiDevices: true
wifiDevices: {
where: {
status: 'ONLINE'
}
}
}
})
}