first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import {Injectable} from "@nestjs/common";
|
||||
import {PrismaService} from "../../prisma/prisma.service";
|
||||
import {Post, Prisma} from "../generated/prisma/client";
|
||||
|
||||
@Injectable()
|
||||
export class PgPostService {
|
||||
constructor(private prisma: PrismaService) {
|
||||
}
|
||||
|
||||
async post(postWhereUniqueInput: Prisma.PostWhereUniqueInput): Promise<Post | null> {
|
||||
return this.prisma.post.findUnique({
|
||||
where: postWhereUniqueInput,
|
||||
});
|
||||
}
|
||||
|
||||
async createPost(data: Prisma.PostCreateInput): Promise<Post> {
|
||||
return this.prisma.post.create({
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
async updatePost(id, data: Prisma.PostUpdateInput): Promise<Post> {
|
||||
return this.prisma.post.update({
|
||||
data,
|
||||
where: {
|
||||
id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user