refactor: made project service to use pagination
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
import { TMProject } from "../entities/project.entity";
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { TMProject } from '../entities/project.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ProjectRepository {
|
||||
@@ -10,23 +10,27 @@ export class ProjectRepository {
|
||||
private readonly repository: Repository<TMProject>,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
return this.repository.find({
|
||||
relations: ["workspace", "taskPhases", "users"],
|
||||
findAll(skip: number, take: number) {
|
||||
return this.repository.findAndCount({
|
||||
relations: ['workspace', 'taskPhases', 'users'],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
}
|
||||
|
||||
findByWorkspace(workspaceId: string) {
|
||||
return this.repository.find({
|
||||
findByWorkspace(workspaceId: string, skip: number, take: number) {
|
||||
return this.repository.findAndCount({
|
||||
where: { workspaceId },
|
||||
relations: ["taskPhases", "users"],
|
||||
relations: ['taskPhases', 'users'],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
}
|
||||
|
||||
findOneById(id: string) {
|
||||
return this.repository.findOne({
|
||||
where: { id },
|
||||
relations: ["workspace", "taskPhases", "users"],
|
||||
relations: ['workspace', 'taskPhases', 'users'],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,4 +49,4 @@ export class ProjectRepository {
|
||||
delete(id: string) {
|
||||
return this.repository.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user