mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
Add prisma
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -36,3 +36,7 @@ yarn-error.log*
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
||||
# prisma
|
||||
**/migrations/
|
||||
**/*.db
|
@ -14,6 +14,7 @@
|
||||
"@mdx-js/loader": "^1.6.22",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"@next/mdx": "^12.0.8",
|
||||
"@prisma/client": "^3.8.1",
|
||||
"algoliasearch": "^4.12.0",
|
||||
"classnames": "^2.3.1",
|
||||
"date-fns": "^2.28.0",
|
||||
@ -55,6 +56,7 @@
|
||||
"jest": "^27.4.7",
|
||||
"postcss": "^8.4.5",
|
||||
"prettier": "^2.5.1",
|
||||
"prisma": "^3.8.1",
|
||||
"tailwindcss": "^3.0.13",
|
||||
"typescript": "4.5.4"
|
||||
}
|
||||
|
@ -1,13 +1,25 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { PrismaClient, Users } from '@prisma/client';
|
||||
|
||||
type Data = {
|
||||
name: string;
|
||||
};
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export default function handler(
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<Data>
|
||||
res: NextApiResponse
|
||||
) {
|
||||
res.status(200).json({ name: 'xfy!' });
|
||||
const test = await prisma.users.findFirst({
|
||||
where: {
|
||||
username: 'test',
|
||||
},
|
||||
select: {
|
||||
username: true,
|
||||
Tweets: {
|
||||
select: {
|
||||
content: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
res.status(200).json(test);
|
||||
}
|
||||
|
@ -147,6 +147,7 @@ const Post = ({ postData }: InferGetStaticPropsType<typeof getStaticProps>) => {
|
||||
<div ref={targetRef} className={'mt-8 min-h-[349px]'}>
|
||||
{inView && <PostComment />}
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
</main>
|
||||
|
||||
|
27
prisma/schema.prisma
Normal file
27
prisma/schema.prisma
Normal file
@ -0,0 +1,27 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Users {
|
||||
id String @id @default(uuid())
|
||||
emil String
|
||||
username String
|
||||
password String
|
||||
Tweets Tweets[]
|
||||
}
|
||||
|
||||
model Tweets {
|
||||
id String @id @default(uuid())
|
||||
content String
|
||||
Users Users? @relation(fields: [usersId], references: [id])
|
||||
usersId String?
|
||||
createAt DateTime
|
||||
}
|
24
yarn.lock
24
yarn.lock
@ -840,6 +840,23 @@
|
||||
"@nodelib/fs.scandir" "2.1.5"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@prisma/client@^3.8.1":
|
||||
version "3.8.1"
|
||||
resolved "https://registry.npmmirror.com/@prisma/client/download/@prisma/client-3.8.1.tgz#c11eda8e84760867552ffde4de7b48fb2cf1e1c0"
|
||||
integrity sha512-NxD1Xbkx1eT1mxSwo1RwZe665mqBETs0VxohuwNfFIxMqcp0g6d4TgugPxwZ4Jb4e5wCu8mQ9quMedhNWIWcZQ==
|
||||
dependencies:
|
||||
"@prisma/engines-version" "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
|
||||
|
||||
"@prisma/engines-version@3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f":
|
||||
version "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
|
||||
resolved "https://registry.npmmirror.com/@prisma/engines-version/download/@prisma/engines-version-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz#4c8d9744b5e54650a8ba5fde0a711399d6adba24"
|
||||
integrity sha512-G2JH6yWt6ixGKmsRmVgaQYahfwMopim0u/XLIZUo2o/mZ5jdu7+BL+2V5lZr7XiG1axhyrpvlyqE/c0OgYSl3g==
|
||||
|
||||
"@prisma/engines@3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f":
|
||||
version "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
|
||||
resolved "https://registry.npmmirror.com/@prisma/engines/download/@prisma/engines-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz#4479099b99f6a082ce5843ee7208943ccedd127f"
|
||||
integrity sha512-bHYubuItSN/DGYo36aDu7xJiJmK52JOSHs4MK+KbceAtwS20BCWadRgtpQ3iZ2EXfN/B1T0iCXlNraaNwnpU2w==
|
||||
|
||||
"@rushstack/eslint-patch@^1.0.8":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmmirror.com/@rushstack/eslint-patch/download/@rushstack/eslint-patch-1.1.0.tgz#7f698254aadf921e48dda8c0a6b304026b8a9323"
|
||||
@ -5113,6 +5130,13 @@ pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.4.6:
|
||||
ansi-styles "^5.0.0"
|
||||
react-is "^17.0.1"
|
||||
|
||||
prisma@^3.8.1:
|
||||
version "3.8.1"
|
||||
resolved "https://registry.npmmirror.com/prisma/download/prisma-3.8.1.tgz#44395cef7cbb1ea86216cb84ee02f856c08a7873"
|
||||
integrity sha512-Q8zHwS9m70TaD7qI8u+8hTAmiTpK+IpvRYF3Rgb/OeWGQJOMgZCFFvNCiSfoLEQ95wilK7ctW3KOpc9AuYnRUA==
|
||||
dependencies:
|
||||
"@prisma/engines" "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.nlark.com/process-nextick-args/download/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
|
Reference in New Issue
Block a user