introduce TRPC and service layer

This commit is contained in:
Michael Dausmann
2023-02-05 11:55:49 +11:00
parent 791192a1ae
commit bba070d985
13 changed files with 307 additions and 58 deletions

View File

@@ -0,0 +1,29 @@
import { PrismaClient } from '@prisma/client';
export default class NotesService {
private prisma: PrismaClient;
constructor( prisma: PrismaClient) {
this.prisma = prisma;
}
async getAllNotes() {
return this.prisma.note.findMany();
}
async getNotesForAccountId(account_id: number) {
return this.prisma.note.findMany({ where: { account_id } });
}
async createNote( account_id: number, note_text: string ) {
return this.prisma.note.create({ data: { account_id, note_text }});
}
async updateNote(id: number, note_text: string) {
return this.prisma.note.update({ where: { id }, data: { note_text } });
}
async deleteNote(id: number) {
return this.prisma.note.delete({ where: { id } });
}
}