website/app/models/posts.server.ts
2023-03-02 08:19:18 +01:00

28 lines
449 B
TypeScript

import { db } from "~/utils/db.server";
export const findPosts = async () => {
return db.post.findMany({
where: {
isPublic: true,
},
select: {
id: true,
title: true,
description: true,
createdAt: true,
},
orderBy: {
createdAt: "desc",
},
});
};
export const findPost = async (id: string) => {
return db.post.findFirst({
where: {
id,
isPublic: true,
},
});
};