mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
29 lines
759 B
JavaScript
29 lines
759 B
JavaScript
import prisma from 'lib/prisma';
|
|
import redis from 'lib/redis';
|
|
|
|
export async function deleteWebsite(website_id) {
|
|
const { client, transaction } = prisma;
|
|
|
|
return transaction([
|
|
client.pageview.deleteMany({
|
|
where: { session: { website: { website_id } } },
|
|
}),
|
|
client.event_data.deleteMany({
|
|
where: { event: { session: { website: { website_id } } } },
|
|
}),
|
|
client.event.deleteMany({
|
|
where: { session: { website: { website_id } } },
|
|
}),
|
|
client.session.deleteMany({
|
|
where: { website: { website_id } },
|
|
}),
|
|
client.website.delete({
|
|
where: { website_id },
|
|
}),
|
|
]).then(async res => {
|
|
if (process.env.REDIS_URL) {
|
|
await redis.client.del(`website:${res.website_uuid}`);
|
|
}
|
|
});
|
|
}
|