MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / constructor

Method constructor

packages/core/src/MikroORM.ts:152–171  ·  view source on GitHub ↗

* Synchronous variant of the `init` method with some limitations: * - folder-based discovery not supported * - ORM extensions are not autoloaded * - when metadata cache is enabled, `FileCacheAdapter` needs to be explicitly set in the config

(options: Partial<Options<Driver, EM, Entities>>)

Source from the content-addressed store, hash-verified

150 * - when metadata cache is enabled, `FileCacheAdapter` needs to be explicitly set in the config
151 */
152 constructor(options: Partial<Options<Driver, EM, Entities>>) {
153 const env = loadEnvironmentVars();
154 options = options.preferEnvVars ? Utils.merge(options, env) : Utils.merge(env, options);
155 this.config = new Configuration(options);
156 const discovery = this.config.get('discovery');
157 this.driver = this.config.getDriver();
158 this.#logger = this.config.getLogger();
159 this.#logger.log('info', `MikroORM version: ${colors.green(Utils.getORMVersion())}`);
160 this.#discovery = new MetadataDiscovery(new MetadataStorage(), this.driver.getPlatform(), this.config);
161 this.driver.getPlatform().init(this as unknown as MikroORM);
162
163 for (const extension of this.config.get('extensions')) {
164 extension.register(this as unknown as MikroORM);
165 }
166
167 if (!discovery.skipSyncDiscovery) {
168 this.#metadata = this.#discovery.discoverSync();
169 this.createEntityManager();
170 }
171 }
172
173 /**
174 * Connects to the database.

Callers

nothing calls this directly

Calls 12

createEntityManagerMethod · 0.95
loadEnvironmentVarsFunction · 0.85
getORMVersionMethod · 0.80
discoverSyncMethod · 0.80
getMethod · 0.65
getLoggerMethod · 0.65
logMethod · 0.65
getPlatformMethod · 0.65
initMethod · 0.65
mergeMethod · 0.45
getDriverMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected