So basically I'm trying for the first time bun with the Elysia framework and prisma for the ORM.
Here is my schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
name String?
}
and here is my seed.ts
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient()
async function main()
{
await prisma.user.create({
data:
{
name: "John Dough",
email: `john-${Math.random()}@example.com`
},
})
const count = await prisma.user.count()
console.log(`There are ${count} users in the database.`)
}
main()
.then(async () => {
console.log("done ! GG !")
await prisma.$disconnect()
})
.catch(async (error) => {
console.error(error)
await prisma.$disconnect()
process.exit(1)
})
And here is my package.json
{
"name": "elysia",
"version": "1.0.50",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "bun run --watch src/index.ts",
"seed": "bunx prisma db seed"
},
"dependencies": {
"@elysiajs/swagger": "^0.7.3",
"@prisma/client": "^5.3.1",
"bson": "^6.1.0",
"elysia": "latest",
"prisma": "^5.3.1"
},
"devDependencies": {
"bun-types": "latest"
},
"module": "src/index.ts",
"prisma": {
"seed": "bun utils/seed.ts"
}
}
So, the issue is that the command "bunx prisma db push" works perfectly, it reads my schema.prisma , create the associated collections and "generate" my prisma client.
But the issue is that the "bun seed" command who basically do "bunx prisma db seed" who basically also do "bun utils/seed.ts" (that I also tried to do by hand) show this :
$ bunx prisma db seed
Environment variables loaded from .env
Running seed command `bun utils/seed.ts` ...
🌱 The seed command has been executed.
but in my database nothing was seeded, and strangely the console.log in the .then of the main seems to not being applied.
Okay so it seems it is a bug from bun side ! Here is the workaround statement peeps made : github comment
Not on the end of prisma hope it will solved soon !