[GH-ISSUE #215] Prisma Support for MongoDB Adapter #8174

Closed
opened 2026-04-13 03:16:25 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @csyedbilal on GitHub (Oct 17, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/215

I’ve considered using native MongoDB drivers or Mongoose for these features, but this adds complexity to my projects by requiring me to mix technologies. It would be much more efficient and streamlined if Prisma could handle these features natively without needing additional libraries.

Originally created by @csyedbilal on GitHub (Oct 17, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/215 I’ve considered using native MongoDB drivers or Mongoose for these features, but this adds complexity to my projects by requiring me to mix technologies. It would be much more efficient and streamlined if Prisma could handle these features natively without needing additional libraries.
GiteaMirror added the locked label 2026-04-13 03:16:25 -05:00
Author
Owner

@Bekacru commented on GitHub (Oct 18, 2024):

mongodb should be supported on the latest release

<!-- gh-comment-id:2421638621 --> @Bekacru commented on GitHub (Oct 18, 2024): mongodb should be supported on the latest release
Author
Owner

@csyedbilal commented on GitHub (Oct 18, 2024):

@Bekacru mongodb worked but

B:\better-auth>bunx @better-auth/cli generate
√ Do you want to generate the schema to ./prisma/schema.prisma? ... yes
🚀 Schema was generated successfully! Better Auth

B:\huc-projects\with-better-auth>

image
image

seen there errors on schema files

<!-- gh-comment-id:2423169437 --> @csyedbilal commented on GitHub (Oct 18, 2024): @Bekacru mongodb worked but B:\better-auth>bunx @better-auth/cli generate √ Do you want to generate the schema to ./prisma/schema.prisma? ... yes ✔ 🚀 Schema was generated successfully! Better Auth B:\huc-projects\with-better-auth> ![image](https://github.com/user-attachments/assets/218186d9-8a12-41a3-9cae-8fa02fd540ab) ![image](https://github.com/user-attachments/assets/03ba5db8-427f-4e3d-a4cb-2f2fa5b8b279) seen there errors on schema files
Author
Owner

@Bekacru commented on GitHub (Oct 18, 2024):

yeah the cli needs to be fixed. let's leave this open until that's addressed.

<!-- gh-comment-id:2423181343 --> @Bekacru commented on GitHub (Oct 18, 2024): yeah the cli needs to be fixed. let's leave this open until that's addressed.
Author
Owner

@csyedbilal commented on GitHub (Oct 19, 2024):

@Bekacru
[{
"resource": "/B:/with-better-auth/prisma/schema.prisma",
"owner": "generated_diagnostic_collection_name#0",
"severity": 8,
"message": "Error validating field user in model Session: The relation field user on model Session is missing an opposite relation field on the model User. Either run prisma format or add it manually.",
"source": "Prisma",
"startLineNumber": 35,
"startColumn": 3,
"endLineNumber": 36,
"endColumn": 1
},{
"resource": "/B:/with-better-auth/prisma/schema.prisma",
"owner": "generated_diagnostic_collection_name#0",
"severity": 8,
"message": "Error validating field user in model Account: The relation field user on model Account is missing an opposite relation field on the model User. Either run prisma format or add it manually.",
"source": "Prisma",
"startLineNumber": 45,
"startColumn": 3,
"endLineNumber": 46,
"endColumn": 1
}]

"better-auth": "^0.5.2-beta.2",
"@better-auth/cli": "^0.5.2-beta.2",

image

<!-- gh-comment-id:2423842942 --> @csyedbilal commented on GitHub (Oct 19, 2024): @Bekacru [{ "resource": "/B:/with-better-auth/prisma/schema.prisma", "owner": "_generated_diagnostic_collection_name_#0", "severity": 8, "message": "Error validating field `user` in model `Session`: The relation field `user` on model `Session` is missing an opposite relation field on the model `User`. Either run `prisma format` or add it manually.", "source": "Prisma", "startLineNumber": 35, "startColumn": 3, "endLineNumber": 36, "endColumn": 1 },{ "resource": "/B:/with-better-auth/prisma/schema.prisma", "owner": "_generated_diagnostic_collection_name_#0", "severity": 8, "message": "Error validating field `user` in model `Account`: The relation field `user` on model `Account` is missing an opposite relation field on the model `User`. Either run `prisma format` or add it manually.", "source": "Prisma", "startLineNumber": 45, "startColumn": 3, "endLineNumber": 46, "endColumn": 1 }] "better-auth": "^0.5.2-beta.2", "@better-auth/cli": "^0.5.2-beta.2", ![image](https://github.com/user-attachments/assets/5b50434b-ba98-4f13-969d-068a9995c744)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8174