Skip to content

@joakimbugge/typeorm-seeder


@joakimbugge/typeorm-seeder / loadEntities

Function: loadEntities()

ts
function loadEntities(sources): Promise<EntityConstructor[]>;

Defined in: packages/seeder/src/utils/loadEntities.ts:16

Resolves a mixed array of entity constructors and glob patterns into a flat array of entity constructors.

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'])

Released under the MIT License.