Added types to database/teams
This commit is contained in:
parent
e9e92c6e9e
commit
68f9bca054
@ -1,9 +1,10 @@
|
||||
import type { Team, Permission } from '@prisma/client';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listTeams() {
|
||||
export async function listTeams(): Promise<Team[]> {
|
||||
return await prisma.team.findMany();
|
||||
}
|
||||
export async function newTeam({ name, userId }) {
|
||||
export async function newTeam({ name, userId }: { name: string; userId: string }): Promise<Team> {
|
||||
return await prisma.team.create({
|
||||
data: {
|
||||
name,
|
||||
@ -12,7 +13,11 @@ export async function newTeam({ name, userId }) {
|
||||
}
|
||||
});
|
||||
}
|
||||
export async function getMyTeams({ userId }) {
|
||||
export async function getMyTeams({
|
||||
userId
|
||||
}: {
|
||||
userId: string;
|
||||
}): Promise<(Permission & { team: Team & { _count: { users: number } } })[]> {
|
||||
return await prisma.permission.findMany({
|
||||
where: { userId },
|
||||
include: { team: { include: { _count: { select: { users: true } } } } }
|
||||
|
Loading…
x
Reference in New Issue
Block a user