Skip to content

Commit

Permalink
Add service for retrieving a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Jan 18, 2024
1 parent 1c80bbf commit af82f93
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion backend/src/workspaces/workspaces.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from "@nestjs/common";
import { Injectable, NotFoundException } from "@nestjs/common";
import { Workspace } from "@prisma/client";
import { PrismaService } from "src/db/prisma.service";

Expand All @@ -23,4 +23,23 @@ export class WorkspacesService {

return workspace;
}

async findOne(userId: string, workspaceId: string) {
try {
await this.prismaService.userWorkspace.findFirstOrThrow({
where: {
userId,
workspaceId,
},
});
} catch (e) {
throw new NotFoundException();
}

return await this.prismaService.workspace.findUnique({
where: {
id: workspaceId,
},
});
}
}

0 comments on commit af82f93

Please sign in to comment.