-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
18 changed files
with
45 additions
and
58 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,11 +1,20 @@ | ||
// cf https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices | ||
|
||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const getClient = () => { | ||
return new PrismaClient(); | ||
}; | ||
declare global { | ||
var prismaClient: PrismaClient | undefined; | ||
} | ||
|
||
const client = | ||
globalThis.prismaClient ?? | ||
new PrismaClient({ | ||
datasources: { | ||
db: { | ||
url: process.env.DATABASE_URL + "&connection_limit=5", | ||
}, | ||
}, | ||
log: ["info", "warn", "error"], | ||
}); | ||
|
||
const client = getClient(); | ||
globalThis.prismaClient = client; | ||
|
||
export default client; |
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,22 +1,18 @@ | ||
// cf https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices | ||
|
||
import { PrismaClient } from "@prisma/client"; | ||
|
||
declare global { | ||
// eslint-disable-next-line no-var | ||
var prisma: PrismaClient | null; | ||
// function getPrismaClient(): PrismaClient; | ||
var prismaClient: PrismaClient | undefined; | ||
} | ||
|
||
const getClient = () => { | ||
if (process.env.NODE_ENV === "production") { | ||
return new PrismaClient(); | ||
} else { | ||
if (!global.prisma) global.prisma = new PrismaClient(); | ||
return global.prisma; | ||
} | ||
}; | ||
|
||
const client = getClient(); | ||
export const client = | ||
globalThis.prismaClient ?? | ||
new PrismaClient({ | ||
datasources: { | ||
db: { | ||
url: process.env.DATABASE_URL + "&connection_limit=5", | ||
}, | ||
}, | ||
log: ["info", "warn", "error"], | ||
}); | ||
|
||
export default client; | ||
globalThis.prismaClient = client; |
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
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
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
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