@joakimbugge/typeorm-seeder / loadEntities
Function: loadEntities()
ts
function loadEntities(sources): Promise<EntityConstructor[]>;Defined in: utils/loadEntities.ts:18
Resolves a mixed array of entity constructors and glob patterns into a flat array of entity constructors — the same format accepted by TypeORM's entities DataSource option.
Constructor entries are passed through as-is. String entries are treated as glob patterns, expanded to file paths, and each matched file is dynamically imported. Every exported value that is a class constructor is collected as an entity.
Parameters
sources
(string | EntityConstructor)[]
Returns
Promise<EntityConstructor[]>
Example
ts
const classes = await loadEntities([User, 'src/entities/*.js'])
const users = await seed(classes).saveMany(10, { dataSource })