fix: db seeding

This commit is contained in:
Juan Di Toro 2023-12-05 17:37:38 +01:00
parent 0df362a891
commit 0990b9c3fd
4 changed files with 615 additions and 615 deletions

1104
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,43 @@
{ {
"name": "web3.news", "name": "web3.news",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"prisma": { "prisma": {
"seed": "ts-node-esm prisma/seed.ts" "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
}, },
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@heroicons/react": "^2.0.18", "@heroicons/react": "^2.0.18",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@prisma/client": "^5.6.0", "@prisma/client": "^5.6.0",
"@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0", "@radix-ui/react-select": "^2.0.0",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"next": "14.0.2", "next": "14.0.2",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",
"tailwind-merge": "^2.0.0", "tailwind-merge": "^2.0.0",
"swr": "^2.2.4" "swr": "^2.2.4"
}, },
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^8.3.1", "@faker-js/faker": "^8.3.1",
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^18", "@types/react": "^18",
"@types/react-dom": "^18", "@types/react-dom": "^18",
"autoprefixer": "^10.0.1", "autoprefixer": "^10.0.1",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "14.0.2", "eslint-config-next": "14.0.2",
"postcss": "^8", "postcss": "^8",
"prisma": "^5.6.0", "prisma": "^5.6.0",
"tailwindcss": "^3.3.0", "tailwindcss": "^3.3.0",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5" "typescript": "^5"
} }
} }

View File

@ -39,7 +39,7 @@ const Feed = ({
revalidateOnReconnect: false, revalidateOnReconnect: false,
shouldRetryOnError: false, shouldRetryOnError: false,
fallbackData: fallbackData:
currentPage === 0 ? { data: initialData, current: 0 } : undefined, // Use initialData only for the first page currentPage === 0 ? { data: initialData, current: 0, next: 5 } : undefined, // Use initialData only for the first page
}, },
); );

View File

@ -39,32 +39,32 @@ export async function fetchFeedData({
} }
} }
// const articles = await prisma.article.findMany({ const articles = await prisma.article.findMany({
// ...query, ...query,
// skip: current, skip: current,
// take: next, take: next,
// }); });
const articles: Article[] = [ // const articles: Article[] = [
{ // {
id: 1, // id: 1,
title: "Mock Article 1", // title: "Mock Article 1",
slug: "This is a mock article.", // slug: "This is a mock article.",
siteKey: "asdas", // siteKey: "asdas",
url: "asdasd", // url: "asdasd",
createdAt: new Date(), // createdAt: new Date(),
updatedAt: new Date(), // updatedAt: new Date(),
}, // },
{ // {
id: 2, // id: 2,
title: "Mock Article 2", // title: "Mock Article 2",
slug: "This is a mock article.", // slug: "This is a mock article.",
siteKey: "asdas", // siteKey: "asdas",
url: "asdasd", // url: "asdasd",
createdAt: new Date(), // createdAt: new Date(),
updatedAt: new Date(), // updatedAt: new Date(),
}, // },
]; // ];
const nextPointer = articles.length >= limit ? next + limit : null; const nextPointer = articles.length >= limit ? next + limit : null;