umami/queries/admin/userWebsite.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-11-18 07:27:33 +01:00
import { Prisma, UserWebsite } from '@prisma/client';
import prisma from 'lib/prisma';
2022-11-18 09:27:42 +01:00
export async function createUserWebsite(
data: Prisma.UserWebsiteCreateInput | Prisma.UserWebsiteUncheckedCreateInput,
): Promise<UserWebsite> {
2022-11-18 07:27:33 +01:00
return prisma.client.userWebsite.create({
data,
});
}
2022-11-19 03:49:58 +01:00
export async function getUserWebsite(where: Prisma.UserWebsiteWhereInput): Promise<UserWebsite> {
return prisma.client.userWebsite.findFirst({
2022-11-18 07:27:33 +01:00
where,
});
}
export async function getUserWebsites(where: Prisma.UserWebsiteWhereInput): Promise<UserWebsite[]> {
return prisma.client.userWebsite.findMany({
where,
});
}
export async function updateUserWebsite(
data: Prisma.UserWebsiteUpdateInput,
where: Prisma.UserWebsiteWhereUniqueInput,
): Promise<UserWebsite> {
return prisma.client.userWebsite.update({
data,
where,
});
}
export async function deleteUserWebsite(userWebsiteId: string): Promise<UserWebsite> {
return prisma.client.userWebsite.update({
data: {
isDeleted: true,
},
where: {
id: userWebsiteId,
},
});
}