Hello i ve been having some problems with typeorm, i am trying to add a new entity to my current project, and i do the following :
i created a new entity
import { Entity, Column, PrimaryGeneratedColumn, JoinColumn, OneToOne } from 'typeorm';
@Entity()
export class Requirement {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column()
seats: number;
@Column()
points: number;
}
and added it to my module
TypeOrmModule.forFeature([Requirement, ....)]
and the table gets correctly created in the database.
i have created a test function to call:
async test(){
const req = new Requirement();
req.seats = 6;
req.points = 40;
return this.requirementRepository.save(req);
}
this is how i created the repository :
@InjectRepository(Requirement)
private readonly requirementRepository: Repository<Requirement>,
i get this error
EntityMetadataNotFoundError: No metadata for "Requirement" was found.
at DataSource.getMetadata (/home/m/work/c/Website-Backend/src/data-source/DataSource.ts:427:30)
at Repository.get metadata [as metadata] (/home/m/work/c/Website-Backend/src/repository/Repository.ts:52:40)
at Repository.save (/home/m/work/c/Website-Backend/src/repository/Repository.ts:205:18)
at ProgramsService.test (/home/m/work/c/Website-Backend/libs/programs/src/programs.service.ts:38:39)
eventho the table gets correctly created.
Just to clarify the new entity i created is in the same directory of some other entites i already have that correctly works, i ll share my typeormconf:
...
TypeOrmModule.forRoot({
type: 'postgres',
host: process.env.POSTGRES_HOST,
port: 5433,
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
entities: [__dirname + '/**/*.entity{.ts,.js}'],
autoLoadEntities: true,
logging: true,
}),
I am stuck i ve tried every possible way but i cant get it to work, thank you in advance.
It should be all set up accordingly to the documentation, but still having problems.