umami/queries/admin/website/deleteWebsite.js
2022-08-17 17:35:52 -07:00

30 lines
827 B
JavaScript

import { prisma, runQuery } from 'lib/db';
export async function deleteWebsite(website_id) {
return runQuery(
prisma.$transaction([
prisma.pageview.deleteMany({
where: { session: { website: { website_id } } },
}),
prisma.event_data.deleteMany({
where: { event: { session: { website: { website_id } } } },
}),
prisma.event.deleteMany({
where: { session: { website: { website_id } } },
}),
prisma.event.deleteMany({
where: { session: { website: { website_id } } },
}),
prisma.event.deleteMany({
where: { session: { website: { website_id } } },
}),
prisma.session.deleteMany({
where: { website: { website_id } },
}),
prisma.website.delete({
where: { website_id },
}),
]),
);
}