feat: add posts
This commit is contained in:
23
app/models/posts.server.ts
Normal file
23
app/models/posts.server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { db } from "~/utils/db.server";
|
||||
|
||||
export const findPosts = async () => {
|
||||
return db.post.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
description: true,
|
||||
createdAt: true,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const findPost = async (id: string) => {
|
||||
return db.post.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user