Created
March 27, 2019 13:19
-
-
Save manjeshpv/8711c39a811a40a0709f736700091dd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { MongoMemoryServer } = require('mongodb-memory-server'); | |
console.log(MongoMemoryServer) | |
const mongod = new MongoMemoryServer(); | |
const x = async() => { | |
const uri = await mongod.getConnectionString(); | |
const port = await mongod.getPort(); | |
const dbPath = await mongod.getDbPath(); | |
const dbName = await mongod.getDbName(); | |
// some code | |
// ... where you may use `uri` for as a connection string for mongodb or mongoose | |
// you may check instance status, after you got `uri` it must be `true` | |
console.log(uri); // return Object with instance data | |
// you may stop mongod manually | |
// await mongod.stop(); | |
// when mongod killed, it's running status should be `false` | |
mongod.getInstanceInfo(); | |
} | |
x() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment