feat: base pages and news fetching with cron job
This commit is contained in:
15
prisma/prisma.ts
Normal file
15
prisma/prisma.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
// PrismaClient is attached to the `global` object in development to prevent
|
||||
// exhausting your database connection limit.
|
||||
//
|
||||
// Learn more:
|
||||
// https://pris.ly/d/help/next-js-best-practices
|
||||
|
||||
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma = globalForPrisma.prisma || new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
||||
|
||||
export default prisma;
|
||||
30
prisma/schema.prisma
Normal file
30
prisma/schema.prisma
Normal file
@@ -0,0 +1,30 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
|
||||
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @default(cuid()) @id
|
||||
email String? @unique
|
||||
targetingAllowed Boolean @default(false)
|
||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
model News {
|
||||
id Float @unique @id
|
||||
title String
|
||||
text String?
|
||||
type String
|
||||
by String
|
||||
time Float
|
||||
url String?
|
||||
score Float
|
||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||
@@map(name: "news")
|
||||
}
|
||||
Reference in New Issue
Block a user