feat(media): scaffold mvp1 media and portfolio foundation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { PrismaPg } from "@prisma/adapter-pg"
|
||||
import { PrismaClient } from "@prisma/client"
|
||||
import { Pool } from "pg"
|
||||
import { PrismaClient } from "../prisma/generated/client/client"
|
||||
|
||||
const connectionString = process.env.DATABASE_URL
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export { db } from "./client"
|
||||
export { getMediaFoundationSummary, listArtworks, listMediaAssets } from "./media-foundation"
|
||||
export {
|
||||
createPost,
|
||||
deletePost,
|
||||
|
||||
88
packages/db/src/media-foundation.ts
Normal file
88
packages/db/src/media-foundation.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { db } from "./client"
|
||||
|
||||
export async function listMediaAssets(limit = 24) {
|
||||
return db.mediaAsset.findMany({
|
||||
orderBy: { updatedAt: "desc" },
|
||||
take: limit,
|
||||
})
|
||||
}
|
||||
|
||||
export async function listArtworks(limit = 24) {
|
||||
return db.artwork.findMany({
|
||||
orderBy: { updatedAt: "desc" },
|
||||
take: limit,
|
||||
include: {
|
||||
renditions: {
|
||||
select: {
|
||||
id: true,
|
||||
slot: true,
|
||||
mediaAssetId: true,
|
||||
},
|
||||
},
|
||||
galleryLinks: {
|
||||
include: {
|
||||
gallery: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
albumLinks: {
|
||||
include: {
|
||||
album: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
categoryLinks: {
|
||||
include: {
|
||||
category: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tagLinks: {
|
||||
include: {
|
||||
tag: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function getMediaFoundationSummary() {
|
||||
const [mediaAssets, artworks, galleries, albums, categories, tags] = await Promise.all([
|
||||
db.mediaAsset.count(),
|
||||
db.artwork.count(),
|
||||
db.gallery.count(),
|
||||
db.album.count(),
|
||||
db.category.count(),
|
||||
db.tag.count(),
|
||||
])
|
||||
|
||||
return {
|
||||
mediaAssets,
|
||||
artworks,
|
||||
galleries,
|
||||
albums,
|
||||
categories,
|
||||
tags,
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
updatePostInputSchema,
|
||||
} from "@cms/content"
|
||||
import { type CrudAuditHook, type CrudMutationContext, createCrudService } from "@cms/crud"
|
||||
import type { Post } from "@prisma/client"
|
||||
import type { Post } from "../prisma/generated/client/client"
|
||||
|
||||
import { db } from "./client"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user