Terminal Error HTTP Response Error
I'm having an error when i try to create an user using TypeORM and Nest.js
The error says: No metadata for "User" was found. EntityMetadataNotFoundError: No metadata for "User" was found.
I've tried everything i've seen that could be, downgraded TypeORM, changed the DataSource, changed the dir of enitities.
REPO: https://github.com/DevGabrielSoares/movie_catalog
to reproduce error:
There is an issue with your UniqueEntityID type, which converts the id
to an invalid type
In create-user.ts
, you referred to the wrong model without using the Entity in the @InjectRepository
method
@InjectRepository(UserEntity)
create
method return a nested user object inside the user objectto avoid that you can simply used a user object
const user = {
name,
email,
password: hashedPassword,
};
and for saving user to the db used save
method. If you used create
create - Creates a new instance of User. Optionally accepts an object literal with user properties which will be written into newly created user object
instead of that, use save
method
In the database.module.ts file change entities: [UserEntity, MovieEntity]
In the http.module.ts file, change TypeOrmModule.forFeature([UserEntity, MovieEntity])
Because both of these modules refer to the Entities in Typeorm
With All changes, I created a Pull Request for your repository. Pull Request