"userId" as id of user instead of "id"

I want to implement BetterAuth inside an existing application, but the user model has user.userId field as the id, but I see BetterAuth requires it to be user.id is it possible to change this or should I make an additional column for the better auth id?
Solution:
We don't allow custom id names yet. @IceeCold It may be a future we add later down the line however....
Jump to solution
5 Replies
rhys
rhys•2w ago
You should be able to just use custom table names to remap it;
export const auth = betterAuth({
user: {
modelName: "users",
fields: {
id: "userId",
},
}
});
export const auth = betterAuth({
user: {
modelName: "users",
fields: {
id: "userId",
},
}
});
https://www.better-auth.com/docs/concepts/database#custom-table-names
Database | Better Auth
Learn how to use a database with Better Auth.
IceeCold
IceeColdOP•2w ago
unfortunately id is not a field you can remap 'Partial<Record<"name" | "image" | "email" | "emailVerified" | "createdAt" | "updatedAt", string>>' only these props
rhys
rhys•2w ago
Ahh... That might be tricky. If they don't allow you to remap id, then it's probably for a good reason.
Solution
Ping
Ping•2w ago
We don't allow custom id names yet. @IceeCold It may be a future we add later down the line however.
IceeCold
IceeColdOP•2w ago
Okay cool thanks 🙂

Did you find this page helpful?