(replicaSet = false, overrideOptions: Partial<Options> = {})
| 60 | let ensureIndexes = true; // ensuring indexes is slow, and it is enough to make it once |
| 61 | |
| 62 | export 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 | |
| 88 | export async function initORMMySql<D extends MySqlDriver | MariaDbDriver = MySqlDriver>( |
| 89 | type: 'mysql' | 'mariadb' = 'mysql', |
no test coverage detected