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

Function initORMPostgreSql

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

Source from the content-addressed store, hash-verified

168}
169
170export async function initORMPostgreSql(loadStrategy = LoadStrategy.SELECT_IN, entities: any[] = [], cache = false) {
171 const dbName = `mikro_orm_test_${(Math.random() + 1).toString(36).substring(2)}`;
172 const orm = new MikroORM({
173 entities: [
174 Author2,
175 Address2,
176 Book2,
177 BookTag2,
178 Publisher2,
179 Test2,
180 FooBar2,
181 FooBaz2,
182 FooParam2,
183 Label2,
184 Configuration2,
185 ...entities,
186 ],
187 dbName,
188 baseDir: BASE_DIR,
189 driver: PostgreSqlDriver,
190 debug: ['query', 'query-params'],
191 forceUtcTimezone: true,
192 autoJoinOneToOneOwner: false,
193 logger: i => i,
194 metadataProvider: ReflectMetadataProvider,
195 migrations: { path: BASE_DIR + '/../temp/migrations', snapshot: false },
196 forceEntityConstructor: [FooBar2],
197 loadStrategy,
198 subscribers: [Test2Subscriber],
199 extensions: [Migrator, SeedManager, EntityGenerator],
200 onQuery: sql => `/* foo */ ${sql}`,
201 });
202
203 const buf = await readFile(import.meta.dirname + '/postgre-schema.sql');
204 await orm.em.getConnection().executeDump(buf.toString());
205 Author2Subscriber.log.length = 0;
206 Test2Subscriber.log.length = 0;
207 EverythingSubscriber.log.length = 0;
208 FlushSubscriber.log.length = 0;
209
210 return orm;
211}
212
213export async function initORMPglite(loadStrategy = LoadStrategy.SELECT_IN, entities: any[] = []) {
214 const orm = new MikroORM<PgliteDriver>({

Calls 4

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

Tested by

no test coverage detected