better-auth+prisma+mongodb combo literally doesn't work
When the psiam.schema is generated using the better auth cli generate command, I was surprised that all the ids didn't have the @db.ObjectId
I ignored that at first glance, but then I hit a wall where I literally can't work anymore..
in my user/[id] page I have a server action that fetches the user by id with prisma. The id is right but I get this issue
The server action;
The error
This means that the better-auth is assigning IDs the wrong way in all the models it creates.. Adding the @db.ObjectId to the User's ID error's the creationg of the user (also adding it to any model that was generated by better-auth)

2 Replies
https://github.com/better-auth/better-auth/issues/4106
I created a github issue for this
GitHub
better auth+prisma+mongodb combo literally doesn't work · Issue #4...
Is this suited for github? Yes, this is suited for github To Reproduce When the psiam.schema is generated using the better auth cli generate command, I was surprised that all the ids didn't hav...
Solution
I found this solution:
Solution:
1- in auth.ts add the following:
2- Change all the ID's of the models generated by better-auth (Session, Account, Verification, User) from to