-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e097b4
commit f7ecc8f
Showing
10 changed files
with
225 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.dist/ | ||
.vscode/ | ||
packages/elegant-ui/node_modules/ | ||
node_modules/ | ||
node_modules/ | ||
source/elegant/src/utils/PrismaRepository.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
'use server' | ||
|
||
import prisma from "@/utils/Prisma"; | ||
|
||
export interface CreateCollection { | ||
title: string; | ||
coverImage: string; | ||
}; | ||
|
||
export async function createCollection(collection: CreateCollection) { | ||
try { | ||
const response = await prisma.collection.create({ | ||
data: collection | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export interface GetCollectionByName { | ||
title: string; | ||
}; | ||
|
||
export async function getCollectionByName(collection: GetCollectionByName) { | ||
|
||
}; | ||
|
||
export interface UpdateCollection { | ||
id: string; | ||
title: string; | ||
coverImage: string; | ||
}; | ||
|
||
export async function updateCollection(collection: UpdateCollection) { | ||
try { | ||
const response = await prisma.collection.update({ | ||
where: { | ||
id: collection.id, | ||
}, | ||
data: collection | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export interface DeleteCollection { | ||
id: string; | ||
} | ||
|
||
export async function deleteCollection(collection: DeleteCollection) { | ||
try { | ||
const response = await prisma.collection.delete({ | ||
where: { | ||
id: collection.id, | ||
} | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use server' | ||
|
||
import prisma from "@/utils/Prisma"; | ||
|
||
export interface CreatePost { | ||
title: string; | ||
status: "DRAFT" | "PUBLISHED"; | ||
description: string; | ||
coverImage: string; | ||
content: string; | ||
authorId: string; | ||
slug: string; | ||
collection: string; | ||
tags: string[]; | ||
}; | ||
|
||
export async function createPost(post: CreatePost) { | ||
try { | ||
const response = await prisma.post.create({ | ||
data: post | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export interface GetPostById { | ||
id: string; | ||
} | ||
|
||
export async function getPostById(post: GetPostById) { | ||
try { | ||
const response = await prisma.post.findUnique({ | ||
where: { | ||
id: post.id, | ||
} | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export interface GetPostByTitle { | ||
name: string; | ||
} | ||
|
||
export async function getPostByTitle(post: GetPostByTitle) { | ||
try { | ||
const response = await prisma.post.findFirst({ | ||
where: { | ||
title: post.name, | ||
} | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export interface UpdatePost { | ||
id: string; | ||
} | ||
|
||
export async function updatePost(post: UpdatePost) { | ||
try { | ||
const response = await prisma.post.findFirst({ | ||
where: { | ||
id: post.id, | ||
} | ||
}); | ||
|
||
return response; | ||
} | ||
catch (error: any) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
} | ||
|
||
export async function deletePost() { | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { mockDeep, mockReset, DeepMockProxy } from 'jest-mock-extended'; | ||
|
||
import prisma from './../Prisma'; | ||
|
||
jest.mock('./../Prisma', () => ({ | ||
__esModule: true, | ||
default: mockDeep<PrismaClient>(), | ||
})); | ||
|
||
beforeEach(() => { | ||
mockReset(prismaMock); | ||
}); | ||
|
||
export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>; |