Skip to content

Instantly share code, notes, and snippets.

@paulodutra
Last active August 11, 2024 17:04
Show Gist options
  • Save paulodutra/5cabb95edb94bd85965e2e2272091787 to your computer and use it in GitHub Desktop.
Save paulodutra/5cabb95edb94bd85965e2e2272091787 to your computer and use it in GitHub Desktop.
Task repository
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