api and lib fixes (#1643)

This commit is contained in:
Brian Cao authored and GitHub committed 2022-11-08 11:55:02 -08:00
1 parent 168283bf11
commit 13fd3ccd16
9 files changed
+30 -29

No files matched your search

+10 -4
View File
@@ -8,19 +8,25 @@ export async function deleteUser(userId) {
where: { userId },
});
let websiteIds = [];
if (websites.length > 0) {
websiteIds = websites.map(a => a.id);
}
return client
.$transaction([
client.pageview.deleteMany({
where: { session: { website: { userId } } },
where: { websiteId: { in: websiteIds } },
}),
client.eventData.deleteMany({
where: { event: { session: { website: { userId } } } },
where: { event: { websiteId: { in: websiteIds } } },
}),
client.event.deleteMany({
where: { session: { website: { userId } } },
where: { websiteId: { in: websiteIds } },
}),
client.session.deleteMany({
where: { website: { userId } },
where: { websiteId: { in: websiteIds } },
}),
client.website.deleteMany({
where: { userId },