-
Notifications
You must be signed in to change notification settings - Fork 4
/
sample.service.ts
executable file
·27 lines (22 loc) · 813 Bytes
/
sample.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Injectable } from '@nestjs/common';
import type { Prisma, Memo } from '@prisma/client';
import { PrismaService } from 'nestjs-prisma';
/**
* https://www.prisma.io/docs/concepts/components/prisma-client/crud
*/
@Injectable()
export class SampleService {
constructor(private prisma: PrismaService) {}
public async create(data: Prisma.MemoCreateInput): Promise<Memo> {
return this.prisma.memo.create({ data });
}
public async read(id: number): Promise<Memo | null> {
return this.prisma.memo.findUnique({ where: { id } });
}
public async update(id: number, data: Prisma.MemoUpdateInput): Promise<Memo> {
return this.prisma.memo.update({ data, where: { id } });
}
public async remove(id: number): Promise<Memo> {
return this.prisma.memo.delete({ where: { id } });
}
}