Error on seed:run
See original GitHub issueHello all,
First of all thank you very much for the library is definitely a must! I’ve been trying to implement it in a project and I don’t seem to be able to make it work. Im implementing NestJS 7 with Typeorm and Postgres Could you please help me out?
I keep on having this errors:
EntityMetadataNotFound: No metadata for <ENTITY_here> was found.
Error: Could not save entity
at EntityFactory.<anonymous> (.........../node_modules/typeorm-seeding/src/entity-factory.ts:52:15)
Output of the seed:config without the database configurations
{
type: 'postgres',
url: undefined,
sid: undefined,
schema: undefined,
extra: undefined,
synchronize: false,
dropSchema: false,
migrationsRun: false,
entities: [ 'src/**/*.entity{.ts', '.js}' ],
migrations: [],
migrationsTableName: undefined,
subscribers: [],
logging: [],
logger: undefined,
entityPrefix: undefined,
maxQueryExecutionTime: undefined,
debug: undefined,
cli: {
entitiesDir: undefined,
migrationsDir: undefined,
subscribersDir: undefined
},
cache: undefined,
uuidExtension: undefined,
factories: [ 'src/**/*.factory{.ts,.js}' ],
seeds: [ 'src/**/*.seed{.ts,.js}' ]
}
Im trying with a simple entity, factory and seeder
export default class CreateCats implements Seeder {
public async run(factory: Factory): Promise<void> {
await factory(Cats)().createMany(5);
}
}
define(Cats, (faker: typeof Faker) => {
const cat = new Cats();
cat.name = "CaT";
cat.age = 22;
return cat;
});
@Entity({
name: "cats",
orderBy: {
createdAt: "ASC",
},
})
export class Cats {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
age: number;
}
What am I missing?
Thank you in advance and I really hope I can use this library because it would save me loads of time
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Hololive ERROR - speedrun.com
Hololive ERROR (2022). PC. Leaderboards. Full Game Leaderboard · News Guides Resources Streams Forum Statistics Boosters. Latest News.
Read more >Error code: UUDDLRLRBA - Forum - The Site - speedrun.com
The site is going to be running very slow while elo works on performance improvements. It's been frequently crashing and loading slowly for ......
Read more >Report a site bug - Forum - The Site - speedrun.com
Is anyone else getting HTTP ERROR 500 after a couple seconds after hitting ... Typicall 500's normally result in a server side failure......
Read more >Error on run submission - Forum - Pandemic: The Board Game
Is this game accepting submissions? I get an error when I try to submit a new run. Any ideas? ultimatedoom1996 ...
Read more >Forums / The Site / can't load 1000+ runs - speedrun.com
I think the simplest way they could fix this is just by making leaderboards with over 500 or 1000 just have pages. Pages...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@gerzok for reasons that I still don’t fully understand if I set up an env file with the following key
TYPEORM_CONNECTIONwe see the following connection options.If we omit that specific key we get the configuration we set up in the ormconfig.js
It makes sense that it fails because we see that all the necessary information for the typeorm-seeding to work is not set.
why this is is happening is something that I still don’t know if it’s from typeorm configuration options or something specific from typeorm-seeding. My suspicion is that this is the inner works of typeorm changing the output of the configurations. I was able to put it to work in both cli commands and e2e tests that I have on a NestJS project.
I have a ormconfig.js file in the root that fetches the env’s from a .env file like so
But for the NestJS project I’m actually using the @nestjs/config package to do so and
@gerzok not sure if this will help you but it took me a while and maybe I can unblock you 😃 and hope that this could make sense for the folks that build this library and they can help us further.
I really like what has been done and I will see if I can dig a bit deeper on why we have different configurations when setting up the env’s.
I didnt read this thread carefully and spend so much time with this error. @DiogoBatista said right: if u have
TYPEORM_CONNECTIONorTYPEORM_URLin your .env file then.ormconfigwill be ignored. Just deleteTYPEORM_CONNECTIONandTYPEORM_URLfrom .env and everything will work fine