-
Prisma is simple and useful ORM. But i have a lot of problem with it. Have you tried to use it in your project? What problems do i have now:
I found this solve with using require:
It works.
Looking for a solution.
Looking for a solution. So, how do you use Prisma? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Binary dependencies (I assume yours is just that) can't be bundled. They must be external. |
Beta Was this translation helpful? Give feedback.
-
Edit: Check out this template to get around the difficulties of Electron and Prisma: https://github.com/awohletz/electron-prisma-trpc-example/ I am using Prisma with SQLite and I just put the database in the public folder. On app startup it gets copied into the userData path and I launch Prisma with the copied one (Answering here so that others can see it better) // The "adapted" Prisma client
import { PrismaClient } from "@prisma/client"
export const devDBPath = join(app.getPath("userData"), "devDB.db")
export const productionDBPath = join(app.getPath("userData"), "productionDB.db")
export const dbPath = import.meta.env.DEV ? devDBPath : productionDBPath
export const dbURL = "file:" + dbPath
export default function createPrismaClient() {
const client = new PrismaClient({
datasources: {
db: { url: dbURL },
},
})
return client
} // The "creation" of the database, run at app startup
// The Prisma schema itself uses the one in "public", which then gets copied over for the app
// Check if database exists. If not copy the empty master to make it available
export async function checkDatabase(dbPath: string) {
if (!await checkPathAccessible(dbPath)) {
if (import.meta.env.DEV) {
promises
.copyFile(join(__dirname, "../public/masterDB.db"), dbPath)
.catch(log.error.red)
} else {
promises
.copyFile(join(__dirname, "masterDB.db"), dbPath)
.catch(log.error.red)
}
}
} |
Beta Was this translation helpful? Give feedback.
Binary dependencies (I assume yours is just that) can't be bundled. They must be external.
https://github.com/cawa-93/vite-electron-builder#working-with-dependencies