umami/queries/admin/website/resetWebsite.js

21 lines
547 B
JavaScript
Raw Normal View History

2022-08-28 06:38:35 +02:00
import prisma from 'lib/prisma';
2022-07-12 23:14:36 +02:00
export async function resetWebsite(websiteId) {
2022-08-29 09:02:38 +02:00
const { client, transaction } = prisma;
2022-08-28 06:38:35 +02:00
2022-08-29 09:02:38 +02:00
return transaction([
2022-08-28 06:38:35 +02:00
client.pageview.deleteMany({
where: { session: { website: { id: websiteId } } },
2022-08-28 06:38:35 +02:00
}),
client.eventData.deleteMany({
where: { event: { session: { website: { id: websiteId } } } },
2022-08-28 06:38:35 +02:00
}),
client.event.deleteMany({
where: { session: { website: { id: websiteId } } },
2022-08-28 06:38:35 +02:00
}),
client.session.deleteMany({
where: { website: { id: websiteId } },
2022-08-28 06:38:35 +02:00
}),
2022-09-01 23:54:25 +02:00
]);
2022-07-12 23:14:36 +02:00
}