File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -164,14 +164,26 @@ Environment variables have higher priority than contents of package.json.
164164```js
165165import { MongoMemoryReplSet } from 'mongodb-memory-server';
166166
167- const replSet = new MongoMemoryReplSet ();
167+ const replSet = new MongoMemoryReplSet ({
168+ debug: false ,
169+ replSet: { storageEngine: ' wiredTiger' },
170+ });
168171await replSet.waitUntilRunning();
169172const uri = await mongod.getConnectionString();
170- const port = await mongod.getPort();
171- const dbPath = await mongod.getDbPath();
172- const dbName = await mongod.getDbName();
173-
174- // some code
173+ // or you may obtain the connection config parts:
174+ // const port = await mongod.getPort();
175+ // const dbPath = await mongod.getDbPath();
176+ // const dbName = await mongod.getDbName();
177+
178+ // some code, eg. for mongoose
179+ mongoose.set('useFindAndModify', false);
180+ mongoose.set('useCreateIndex', true);
181+ mongoose.connect(uri, {
182+ useNewUrlParser: true ,
183+ useUnifiedTopology: true ,
184+ });
185+ // after some useful code don't forget to disconnect
186+ mongoose .disconnect ();
175187
176188// stop replica set manually
177189replSet .stop ();
You can’t perform that action at this time.
0 commit comments