canina/backend/src/wiki/wiki.service.ts

22 lines
544 B
TypeScript

import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class WikiService {
constructor(private prisma: PrismaService) {}
async findAll() {
return this.prisma.scientificTerm.findMany({
orderBy: { term: 'asc' }
});
}
async findOneByKey(key: string) {
const term = await this.prisma.scientificTerm.findUnique({
where: { key }
});
if (!term) throw new NotFoundException('Wiki term not found');
return term;
}
}