Add Reset / Delete functionality.
This commit is contained in:
@@ -16,13 +16,7 @@ export async function deleteUser(userId) {
|
||||
|
||||
return client
|
||||
.$transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { websiteId: { in: websiteIds } },
|
||||
}),
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { websiteId: { in: websiteIds } } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
client.websiteEvent.deleteMany({
|
||||
where: { websiteId: { in: websiteIds } },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
|
||||
@@ -5,13 +5,7 @@ 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({
|
||||
client.websiteEvent.deleteMany({
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
import prisma from 'lib/prisma';
|
||||
import { getWebsite } from 'queries';
|
||||
import cache from 'lib/cache';
|
||||
|
||||
export async function resetWebsite(id) {
|
||||
const { client, transaction } = prisma;
|
||||
|
||||
const { revId } = await getWebsite({ id });
|
||||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { websiteId: id } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
client.websiteEvent.deleteMany({
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
]);
|
||||
client.website.update({ where: { id }, data: { revId: revId + 1 } }),
|
||||
]).then(async data => {
|
||||
if (cache.enabled) {
|
||||
await cache.storeWebsite(data[2]);
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user