Last active
August 11, 2024 17:04
-
-
Save paulodutra/5cabb95edb94bd85965e2e2272091787 to your computer and use it in GitHub Desktop.
Task repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { InjectRepository } from '@nestjs/typeorm'; | |
import { Repository } from 'typeorm'; | |
import { Task } from '../entities/task.entity'; | |
@Injectable() | |
export class TaskRepository { | |
constructor( | |
@InjectRepository(Task) | |
private repository: Repository<Task>, | |
) {} | |
async findByStatus(status: string): Promise<Task[]> { | |
return await this.repository | |
.createQueryBuilder('task') | |
.select() | |
.where('task.status = :status', { status }) | |
.getMany(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment