Skip to content

Commit

Permalink
move to types
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Feb 12, 2024
1 parent 27f3b2e commit ee7f005
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
23 changes: 20 additions & 3 deletions utopia-remix/app/models/project.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Project } from 'prisma-client'
import { prisma } from '../db.server'

export type ProjectWithoutContent = Omit<Project, 'content'>
import { ProjectWithoutContent } from '../types'

const selectProjectWithoutContent: Record<keyof ProjectWithoutContent, true> = {
id: true,
Expand Down Expand Up @@ -74,3 +72,22 @@ export async function listDeletedProjects(params: {
orderBy: { modified_at: 'desc' },
})
}

export async function hardDeleteProject(params: { id: string; userId: string }): Promise<void> {
await prisma.project.delete({
where: {
proj_id: params.id,
owner_id: params.userId,
deleted: true,
},
})
}

export async function hardDeleteAllProjects(params: { userId: string }): Promise<void> {
await prisma.project.deleteMany({
where: {
owner_id: params.userId,
deleted: true,
},
})
}
4 changes: 4 additions & 0 deletions utopia-remix/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Project } from 'prisma-client'

export interface ProjectListing {
id: string
ownerName: string | null
Expand All @@ -11,3 +13,5 @@ export interface ProjectListing {
export type ListProjectsResponse = {
projects: ProjectListing[]
}

export type ProjectWithoutContent = Omit<Project, 'content'>

0 comments on commit ee7f005

Please sign in to comment.