mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
31 lines
650 B
JavaScript
31 lines
650 B
JavaScript
import prisma from 'lib/prisma';
|
|
import cache from 'lib/cache';
|
|
|
|
export async function deleteWebsite(id) {
|
|
const { client, transaction } = prisma;
|
|
|
|
return transaction([
|
|
client.pageview.deleteMany({
|
|
where: { websiteId: id },
|
|
}),
|
|
client.eventData.deleteMany({
|
|
where: { event: { websiteId: id } },
|
|
}),
|
|
client.event.deleteMany({
|
|
where: { websiteId: id },
|
|
}),
|
|
client.session.deleteMany({
|
|
where: { websiteId: id },
|
|
}),
|
|
client.website.delete({
|
|
where: { id },
|
|
}),
|
|
]).then(async data => {
|
|
if (cache.enabled) {
|
|
await cache.deleteWebsite(id);
|
|
}
|
|
|
|
return data;
|
|
});
|
|
}
|