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

Function initORMMongo

tests/bootstrap.ts:62–86  ·  view source on GitHub ↗
(replicaSet = false, overrideOptions: Partial<Options> = {})

Source from the content-addressed store, hash-verified

60let ensureIndexes = true; // ensuring indexes is slow, and it is enough to make it once
61
62export async function initORMMongo(replicaSet = false, overrideOptions: Partial<Options> = {}) {
63 const dbName = `mikro-orm-test-${(Math.random() + 1).toString(36).substring(2)}`;
64 const clientUrl = replicaSet ? `${process.env.MONGO_URI}/${dbName}` : `mongodb://localhost:27017/${dbName}`;
65 const orm = await MikroORM.init({
66 entities: ['entities'],
67 preferTs: false,
68 clientUrl,
69 baseDir: BASE_DIR,
70 logger: i => i,
71 driver: MongoDriver,
72 metadataProvider: ReflectMetadataProvider,
73 ensureIndexes,
74 implicitTransactions: replicaSet,
75 filters: { allowedFooBars: { cond: args => ({ id: { $in: args.allowed } }), entity: ['FooBar'], default: false } },
76 pool: { min: 1, max: 3 },
77 migrations: { path: BASE_DIR + '/../temp/migrations-mongo' },
78 ignoreUndefinedInQuery: true,
79 extensions: [MongoMigrator, SeedManager, EntityGenerator],
80 ...overrideOptions,
81 });
82
83 ensureIndexes = false;
84
85 return orm as MikroORM<MongoDriver>;
86}
87
88export async function initORMMySql<D extends MySqlDriver | MariaDbDriver = MySqlDriver>(
89 type: 'mysql' | 'mariadb' = 'mysql',

Calls 2

initMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected