mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
add clickhouse route to deleteWebsite
This commit is contained in:
parent
21072c712c
commit
eaa208652d
@ -1,6 +1,7 @@
|
|||||||
import { Prisma, Website } from '@prisma/client';
|
import { Prisma, Website } from '@prisma/client';
|
||||||
import cache from 'lib/cache';
|
import cache from 'lib/cache';
|
||||||
import prisma from 'lib/prisma';
|
import prisma from 'lib/prisma';
|
||||||
|
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||||
|
|
||||||
export async function createWebsiteByUser(
|
export async function createWebsiteByUser(
|
||||||
userId: string,
|
userId: string,
|
||||||
@ -150,7 +151,14 @@ export async function getAllWebsites(): Promise<(Website & { user: string })[]>
|
|||||||
|
|
||||||
export async function deleteWebsite(
|
export async function deleteWebsite(
|
||||||
websiteId: string,
|
websiteId: string,
|
||||||
): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
|
) {
|
||||||
|
return runQuery({
|
||||||
|
[PRISMA]: () => deleteWebsiteRelationalQuery(websiteId),
|
||||||
|
[CLICKHOUSE]: () => deleteWebsiteClickhouseQuery(websiteId),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteWebsiteRelationalQuery(websiteId): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
|
||||||
const { client, transaction } = prisma;
|
const { client, transaction } = prisma;
|
||||||
|
|
||||||
return transaction([
|
return transaction([
|
||||||
@ -174,3 +182,12 @@ export async function deleteWebsite(
|
|||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteWebsiteClickhouseQuery(websiteId): Promise<Website> {
|
||||||
|
return prisma.client.website.update({
|
||||||
|
data: {
|
||||||
|
isDeleted: true,
|
||||||
|
},
|
||||||
|
where: { id: websiteId },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user