Allow user to be added to team with role.
This commit is contained in:
@@ -1,12 +1,31 @@
|
||||
import { Prisma, TeamUser } from '@prisma/client';
|
||||
import { Prisma, TeamUser, UserRole } from '@prisma/client';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createTeamUser(
|
||||
data: Prisma.TeamUserCreateInput | Prisma.TeamUserUncheckedCreateInput,
|
||||
): Promise<TeamUser> {
|
||||
return prisma.client.teamUser.create({
|
||||
data,
|
||||
});
|
||||
userId: string,
|
||||
teamId: string,
|
||||
roleId: string,
|
||||
): Promise<[TeamUser, UserRole]> {
|
||||
const { client } = prisma;
|
||||
|
||||
return client.$transaction([
|
||||
client.teamUser.create({
|
||||
data: {
|
||||
id: uuid(),
|
||||
userId,
|
||||
teamId,
|
||||
},
|
||||
}),
|
||||
client.userRole.create({
|
||||
data: {
|
||||
id: uuid(),
|
||||
userId,
|
||||
teamId,
|
||||
roleId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function getTeamUser(where: Prisma.TeamUserWhereInput): Promise<TeamUser> {
|
||||
|
||||
Reference in New Issue
Block a user