25 lines
629 B
TypeScript
25 lines
629 B
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { InjectRepository } from "@nestjs/typeorm";
|
|
import { Repository } from "typeorm";
|
|
import { GroupEntity } from "./group.entity";
|
|
import { CreateGroupDto } from "../dto/create-group.dto";
|
|
|
|
@Injectable()
|
|
export class GroupsRepository {
|
|
constructor(
|
|
@InjectRepository(GroupEntity)
|
|
private readonly repo: Repository<GroupEntity>,
|
|
) {}
|
|
|
|
save(group: GroupEntity) {
|
|
return this.repo.save(group);
|
|
}
|
|
|
|
findById(id: string) {
|
|
return this.repo.findOne({ where: { id } });
|
|
}
|
|
|
|
create(dto: CreateGroupDto) {
|
|
return this.repo.save(this.repo.create(dto))
|
|
}
|
|
} |