mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Allow user to be added to team with role.
This commit is contained in:
parent
d85b2be5f8
commit
502facd426
2 changed files with 34 additions and 15 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue