shubhamr238
shubhamr238

Reputation: 1408

Create in-memory database using mongodb-memory-server and mongoose

I want to create a in-memory database using mongodb-memory-server and mongoose. Can anyone show the correct way to do it.

Upvotes: 1

Views: 2079

Answers (1)

McConnell
McConnell

Reputation: 256

From version 7 and above

// this no longer works
const mongo = new MongoMemoryServer();
const uri = await mongo.getUri(); // ERROR: instance not started

// it is now
const mongo = await MongoMemoryServer.create();
const uri = mongo.getUri();

https://nodkz.github.io/mongodb-memory-server/docs/guides/migration/migrate7/#no-function-other-than-start-create-ensureinstance-will-be-starting-anything

Upvotes: 3

Related Questions