I want to make sure I follow best practice etc. Li...
# orm-help
s
I want to make sure I follow best practice etc. Like, should you have all your functions in a single file or is it better to split based on collection for example. If you split by collection, is it ok to create a new Prisma client in each? i.e.
const prisma = new PrismaClient()
or should you instead have a util that returns the client if one does not already exist. I have many more questions like that 🙂
✅ 1
Oh wow, the docs are really amazing 🙂
💚 1
c
Generally you want to use a singleton i.e. run
const prisma = new PrismaClient()
in one
prisma.js
or
prisma.ts
file then import that in each file where it's needed, or depending on your framework import and pass it into context so it's available where it's needed.
👌 1
s