refactor: changed the getUserProjects to get projects in a specific workspace

This commit is contained in:
2026-07-06 13:24:36 +03:30
parent 2590a222b4
commit 5715cbe9b1
4 changed files with 16 additions and 9 deletions
@@ -11,12 +11,14 @@ export class ProjectRepository extends Repository<TMProject> {
super(projectRepository.target, projectRepository.manager, projectRepository.queryRunner);
}
async findUserProjects(userId: string, skip?: number, take?: number): Promise<[TMProject[], number]> {
async findUserProjects(userId: string, wsId: string, skip?: number, take?: number): Promise<[TMProject[], number]> {
return this.createQueryBuilder('project')
.innerJoin('project.workspace', 'workspace')
.innerJoin('project.users', 'user')
.where('user.id = :userId', {userId})
.where('workspace.id = :wsId', {wsId})
.andWhere('user.id = :userId', {userId})
.skip(skip ?? 0)
.take(take ?? 0)
.take(take ?? 10)
.getManyAndCount();
}
}