umami/queries/admin/teamUser.ts

44 lines
1016 B
TypeScript
Raw Normal View History

2022-11-18 07:27:33 +01:00
import { Prisma, TeamUser } from '@prisma/client';
import prisma from 'lib/prisma';
2022-11-18 09:27:42 +01:00
export async function createTeamUser(
data: Prisma.TeamUserCreateInput | Prisma.TeamUserUncheckedCreateInput,
): Promise<TeamUser> {
2022-11-18 07:27:33 +01:00
return prisma.client.teamUser.create({
data,
});
}
export async function getTeamUser(where: Prisma.TeamUserWhereUniqueInput): Promise<TeamUser> {
return prisma.client.teamUser.findUnique({
where,
});
}
export async function getTeamUsers(where: Prisma.TeamUserWhereInput): Promise<TeamUser[]> {
return prisma.client.teamUser.findMany({
where,
});
}
export async function updateTeamUser(
data: Prisma.TeamUserUpdateInput,
where: Prisma.TeamUserWhereUniqueInput,
): Promise<TeamUser> {
return prisma.client.teamUser.update({
data,
where,
});
}
export async function deleteTeamUser(teamUserId: string): Promise<TeamUser> {
return prisma.client.teamUser.update({
data: {
isDeleted: true,
},
where: {
id: teamUserId,
},
});
}