Describe the bug
I'm trying to add custom fields to the user model using TypeORM. I follow the documentation but new fields are not present.
To Reproduce
I have an user Model
import Adapters from 'next-auth/adapters';
export default class User extends Adapters.TypeORM.Models.User.model {
}
export const UserSchema = {
...Adapters.TypeORM.Models.User.schema,
target: User,
columns: {
...Adapters.TypeORM.Models.User.schema.columns,
slug: {
type: 'varchar',
nullable: true,
},
},
};
and I use it in the adapter definition
{
...
adapter: Adapters.TypeORM.Adapter(
// The first argument should be a database connection string or TypeORM config object
process.env.DATABASE_URL,
// The second argument can be used to pass custom models and schemas
{
customModels: {
User: Models.User,
},
}),
...
}
Expected behavior
The user should have a slug field, but no field is present on DB. What am I doing wrong?
Documentation feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
I found the problem, looking at the code the option is models, not customModels. Relevat documentation should be changed here https://next-auth.js.org/tutorials/typeorm-custom-models#using-custom-models
I found the problem, looking at the code the option is
models, notcustomModels. Relevat documentation should be changed here https://next-auth.js.org/tutorials/typeorm-custom-models#using-custom-models
So did you fix the problem by replacing "customModels" with "models"? It still doesn't work for me
Yes, I did and it's working for me
@ramiel Thanks for highlighting the error in the documentation! I've updated it now.
I think that might have been left over from how it was in an old beta (or maybe just the internal name was used by mistake).
When we have a place for example projects sorted out it would be great to have an example that shows custom models.