-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template(db): Update
api/src/lib/db
template (#11379)
Updates the template in `api/src/lib/db.{js,ts}` to export `db` in a different way. This makes it easier to add Prisma client extensions. --------- Co-authored-by: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com>
- Loading branch information
1 parent
28c2daf
commit ddf850d
Showing
4 changed files
with
59 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- template(db): Update `api/src/lib/db` template (#11379) by @dac09 | ||
|
||
Updates the template in `api/src/lib/db.{js,ts}` to export `db` differently. | ||
|
||
In your existing projects, you can make the following changes: | ||
|
||
```diff | ||
|
||
import { PrismaClient } from '@prisma/client' | ||
|
||
import { emitLogLevels, handlePrismaLogging } from '@redwoodjs/api/logger' | ||
|
||
import { logger } from './logger' | ||
import { prismaExtension } from './uploads' | ||
|
||
- export const db = new PrismaClient({ | ||
+ const prismaClient = new PrismaClient({ | ||
log: emitLogLevels(['info', 'warn', 'error']), | ||
}) | ||
|
||
handlePrismaLogging({ | ||
- db | ||
+ db: prismaClient, | ||
logger, | ||
logLevels: ['info', 'warn', 'error'], | ||
}) | ||
|
||
+ export const db = prismaClient | ||
``` |
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