* 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>>)
| 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. |
nothing calls this directly
no test coverage detected