Add drizzle singleton snippet code to docs #688
lucaspiresfernandes
started this conversation in
Ideas
Replies: 1 comment
-
I have issues with this. My page will work fine the first time, but then I'll randomly start getting this error:
I've tried the above singleton, as well as something similar from Prisma's docs. Production seems to work fine though. 🤷♂️ Hmm, I wonder if it has something to do with schema table factories const customersView = getCustomersView(region);
const customers = await database
.select({
contractAmount: customersView.contractAmount,
custName: customersView.custName,
endDate: customersView.endDate,
fullFranName: customersView.fullFranName,
id: customersView.id,
opsTeamName: customersView.opsTeamName,
salesRep: customersView.salesRep,
serviceAddress: customersView.serviceAddress,
startDate: customersView.startDate,
statusName: customersView.statusName,
})
.from(customersView); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In order to use drizzle with Next.js for example, you have to create a singleton connection so that it persists between reloads. It's not clear as how to do it and if you don't, you'll have to restart you development environment every other minute because of the database server complaints. Most people don't know how to set it up and even I struggled to find a solution. Well, now that I have, I would like to share it and I think it would be a good idea to add it to the docs. Here's the code:
Beta Was this translation helpful? Give feedback.
All reactions