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

Function initORMPglite

tests/bootstrap.ts:213–253  ·  view source on GitHub ↗
(loadStrategy = LoadStrategy.SELECT_IN, entities: any[] = [])

Source from the content-addressed store, hash-verified

211}
212
213export async function initORMPglite(loadStrategy = LoadStrategy.SELECT_IN, entities: any[] = []) {
214 const orm = new MikroORM<PgliteDriver>({
215 entities: [
216 Author2,
217 Address2,
218 Book2,
219 BookTag2,
220 Publisher2,
221 Test2,
222 FooBar2,
223 FooBaz2,
224 FooParam2,
225 Label2,
226 Configuration2,
227 ...entities,
228 ],
229 dbName: 'memory://',
230 baseDir: BASE_DIR,
231 driver: PgliteDriver,
232 debug: ['query', 'query-params'],
233 forceUtcTimezone: true,
234 autoJoinOneToOneOwner: false,
235 logger: i => i,
236 metadataProvider: ReflectMetadataProvider,
237 migrations: { path: BASE_DIR + '/../temp/migrations', snapshot: false },
238 forceEntityConstructor: [FooBar2],
239 loadStrategy,
240 subscribers: [Test2Subscriber],
241 extensions: [Migrator, SeedManager, EntityGenerator],
242 onQuery: sql => `/* foo */ ${sql}`,
243 });
244
245 const buf = await readFile(import.meta.dirname + '/postgre-schema.sql');
246 await orm.em.getConnection().executeDump(buf.toString());
247 Author2Subscriber.log.length = 0;
248 Test2Subscriber.log.length = 0;
249 EverythingSubscriber.log.length = 0;
250 FlushSubscriber.log.length = 0;
251
252 return orm;
253}
254
255export async function initORMMsSql(additionalOptions: Partial<Options<MsSqlDriver>> = {}, createSchema = true) {
256 const dbName = `mikro_orm_test_${(Math.random() + 1).toString(36).substring(2)}`;

Callers 1

Calls 4

readFileFunction · 0.85
getConnectionMethod · 0.65
executeDumpMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected