Initial commit
This commit is contained in:
19
packages/db/src/posts.ts
Normal file
19
packages/db/src/posts.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { upsertPostSchema } from "@cms/content"
|
||||
|
||||
import { db } from "./client"
|
||||
|
||||
export async function listPosts() {
|
||||
return db.post.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function createPost(input: unknown) {
|
||||
const payload = upsertPostSchema.parse(input)
|
||||
|
||||
return db.post.create({
|
||||
data: payload,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user