mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Add queries for new schema.
This commit is contained in:
parent
b0c7980a20
commit
5aa8187e42
25 changed files with 699 additions and 306 deletions
56
queries/admin/team.ts
Normal file
56
queries/admin/team.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { Prisma, Role, Team, TeamUser } from '@prisma/client';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createTeam(data: Prisma.RoleCreateInput): Promise<Role> {
|
||||
return prisma.client.role.create({
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTeam(where: Prisma.RoleWhereUniqueInput): Promise<Role> {
|
||||
return prisma.client.role.findUnique({
|
||||
where,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTeams(where: Prisma.RoleWhereInput): Promise<Role[]> {
|
||||
return prisma.client.role.findMany({
|
||||
where,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTeamsByUserId(userId: string): Promise<
|
||||
(TeamUser & {
|
||||
team: Team;
|
||||
})[]
|
||||
> {
|
||||
return prisma.client.teamUser.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
include: {
|
||||
team: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateTeam(
|
||||
data: Prisma.RoleUpdateInput,
|
||||
where: Prisma.RoleWhereUniqueInput,
|
||||
): Promise<Role> {
|
||||
return prisma.client.role.update({
|
||||
data,
|
||||
where,
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteTeam(teamId: string): Promise<Role> {
|
||||
return prisma.client.role.update({
|
||||
data: {
|
||||
isDeleted: true,
|
||||
},
|
||||
where: {
|
||||
id: teamId,
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue