chore: update post model

This commit is contained in:
Andrea 2023-03-02 08:19:18 +01:00
parent 5d870a2e4a
commit bd16bc4fcf
No known key found for this signature in database
GPG Key ID: 4594610B9C8F91C5
2 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,9 @@ import { db } from "~/utils/db.server";
export const findPosts = async () => {
return db.post.findMany({
where: {
isPublic: true,
},
select: {
id: true,
title: true,
@ -15,9 +18,10 @@ export const findPosts = async () => {
};
export const findPost = async (id: string) => {
return db.post.findUnique({
return db.post.findFirst({
where: {
id,
isPublic: true,
},
});
};

View File

@ -15,6 +15,7 @@ model Post {
title String
description String?
path String
isPublic Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}