/** * Stops the store * * @returns {Promise} Success or not? * @memberof Disk */ async stop() { debug('stopping %s', this.name); await super.stop(); await this.mongod.stop(); }
// connect to in-memory mongodb Server // eslint-disable-next-line no-underscore-dangle mongoServer.getUri().then((mongoUri) => { mongoose.connect(mongoUri, mongoOptions); logger.debug('using mongo-memory-server'); });
/** * Starts the store * * @returns {Promise} Resolves or not * @memberof Disk */ async start() { debug('starting %s', this.name); const dataPath = path.join( os.tmpdir(), `henri-mongo-${md5(process.cwd())}` ); if (!fs.existsSync(dataPath)) { fs.mkdirSync(dataPath); } this.mongod = new MongoMemoryServer({ instance: { dbName: 'henri', dbPath: this.henri.isTest ? null : dataPath, storageEngine: this.henri.isTest ? 'ephemeralForTest' : 'wiredTiger', }, }); this.config.url = await this.mongod.getConnectionString(); return super.start(); }