Fix graphql queries
This commit is contained in:
@ -4,51 +4,61 @@ import { PrismaService } from 'src/database/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class UserRepository {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
async findMany(params: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
cursor?: Prisma.UserWhereUniqueInput;
|
||||
where?: Prisma.UserWhereInput;
|
||||
orderBy?: Prisma.UserOrderByWithRelationInput;
|
||||
}): Promise<User[]> {
|
||||
const { skip, take, cursor, where, orderBy } = params;
|
||||
return this.prisma.user.findMany({ skip, take, cursor, where, orderBy });
|
||||
}
|
||||
async findMany(params: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
cursor?: Prisma.UserWhereUniqueInput;
|
||||
where?: Prisma.UserWhereInput;
|
||||
orderBy?: Prisma.UserOrderByWithRelationInput;
|
||||
}): Promise<User[]> {
|
||||
const { skip, take, cursor, where, orderBy } = params;
|
||||
return this.prisma.user.findMany({ skip, take, cursor, where, orderBy });
|
||||
}
|
||||
|
||||
async upsertUser(params: { data: Prisma.UserCreateInput, workspaceId: string }): Promise<User> {
|
||||
const { data } = params;
|
||||
|
||||
return await this.prisma.user.upsert({
|
||||
where: {
|
||||
email: data.email
|
||||
},
|
||||
create: {
|
||||
id: data.id,
|
||||
displayName: data.displayName,
|
||||
email: data.email,
|
||||
locale: data.locale,
|
||||
},
|
||||
update: {
|
||||
}
|
||||
});
|
||||
}
|
||||
async findUnique(params: {
|
||||
where?: Prisma.UserWhereInput;
|
||||
}): Promise<User | null> {
|
||||
const { where } = params;
|
||||
return this.prisma.user.findFirst({ where });
|
||||
}
|
||||
|
||||
async upsertWorkspaceMember(params: { data: Prisma.WorkspaceMemberUncheckedCreateInput }): Promise<WorkspaceMember> {
|
||||
const { data } = params;
|
||||
|
||||
return await this.prisma.workspaceMember.upsert({
|
||||
where: {
|
||||
userId: data.userId
|
||||
},
|
||||
create: {
|
||||
id: data.id,
|
||||
userId: data.userId,
|
||||
workspaceId: data.workspaceId,
|
||||
},
|
||||
update: {
|
||||
}
|
||||
});
|
||||
}
|
||||
async upsertUser(params: {
|
||||
data: Prisma.UserCreateInput;
|
||||
workspaceId: string;
|
||||
}): Promise<User> {
|
||||
const { data } = params;
|
||||
|
||||
return await this.prisma.user.upsert({
|
||||
where: {
|
||||
email: data.email,
|
||||
},
|
||||
create: {
|
||||
id: data.id,
|
||||
displayName: data.displayName,
|
||||
email: data.email,
|
||||
locale: data.locale,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
|
||||
async upsertWorkspaceMember(params: {
|
||||
data: Prisma.WorkspaceMemberUncheckedCreateInput;
|
||||
}): Promise<WorkspaceMember> {
|
||||
const { data } = params;
|
||||
|
||||
return await this.prisma.workspaceMember.upsert({
|
||||
where: {
|
||||
userId: data.userId,
|
||||
},
|
||||
create: {
|
||||
id: data.id,
|
||||
userId: data.userId,
|
||||
workspaceId: data.workspaceId,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,22 +4,34 @@ import { PrismaService } from 'src/database/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceRepository {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
async findMany(params: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
cursor?: Prisma.WorkspaceWhereUniqueInput;
|
||||
where?: Prisma.WorkspaceWhereInput;
|
||||
orderBy?: Prisma.WorkspaceOrderByWithRelationInput;
|
||||
}): Promise<Workspace[]> {
|
||||
const { skip, take, cursor, where, orderBy } = params;
|
||||
return this.prisma.workspace.findMany({ skip, take, cursor, where, orderBy });
|
||||
}
|
||||
async findMany(params: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
cursor?: Prisma.WorkspaceWhereUniqueInput;
|
||||
where?: Prisma.WorkspaceWhereInput;
|
||||
orderBy?: Prisma.WorkspaceOrderByWithRelationInput;
|
||||
}): Promise<Workspace[]> {
|
||||
const { skip, take, cursor, where, orderBy } = params;
|
||||
return this.prisma.workspace.findMany({
|
||||
skip,
|
||||
take,
|
||||
cursor,
|
||||
where,
|
||||
orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
async findUnique(
|
||||
data: Prisma.WorkspaceFindUniqueArgs,
|
||||
): Promise<Workspace | null> {
|
||||
return await this.prisma.workspace.findUnique(data);
|
||||
}
|
||||
async findUnique(
|
||||
params: Prisma.WorkspaceFindUniqueArgs,
|
||||
): Promise<Workspace | null> {
|
||||
return await this.prisma.workspace.findUnique(params);
|
||||
}
|
||||
|
||||
async findFirst(
|
||||
params: Prisma.WorkspaceFindFirstArgs,
|
||||
): Promise<Workspace | null> {
|
||||
return await this.prisma.workspace.findFirst(params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user