Skip to main content

MongoMemoryInstanceOpts

API Documentation of MongoMemoryInstanceOpts-Interface

Values for MongoMemoryInstanceOpts

Inherits from MongoMemoryInstanceOptsBase.

auth

Typings: auth?: boolean
Default: false

Set which option auth argument to add:

  • if true, add --auth
  • if false, add --noauth

This options gets automatically set (overwritten) when using createAuth.

dbName

Typings: dbName?: string

Previously set the dbName for the getUri calls, but currently unused.

ip

Typings: ip?: string

Set the ip to bind to, if defined will add the argument --bind_ip with the input string.

replSet

Typings: replSet?: string

Set the ReplSet name to use, if defined will add the argument --replSet with the input string.

keyfileLocation

Typings: keyfileLocation?: string

Set a custom location for where the keyfile for authentication will be stored, if defined will add the argument --keyfile with the input string.
Only has a effect when used in a MongoMemoryReplSet and auth is enabled.
This option will get automatically set when not manually defined.

Values for MongoMemoryInstanceOptsBase

args

Typings: args?: string[]

Set extra Arguments to add to the started instance, will likely overwrite arguments set by other options, depending on how the binary parses arguments.

port

Typings: port?: number

When set, adds the --port argument with the input.
This options will get automatically set with a free port that is found.

dbPath

Typings: dbPath?: string

When set, adds the --dbpath argument with the input.
This option will automatically be set with a directory generated by mkdtemp.

storageEngine

Typings: storageEngine?: StorageEngine
Default: ephemeralForTest (unless mongodb version is 7.0.0, where its wiredTiger)

Set which storage engine to use, uses StorageEngine.

replicaMemberConfig

Typings: replicaMemberConfig?: ReplicaMemberConfig

Set custom a custom Replica Member Config, uses ReplicaMemberConfig.
Only has a effect when started with MongoMemoryReplSet.

Helper Type StorageEngine

Typings: StorageEngine = 'ephemeralForTest' | 'wiredTiger'

Storage Engines supported by mongodb, see MongoDB Storage Engines.

Custom Explanation:

  • ephemeralForTest is a in-memory storage engine, which stores everything in RAM, which is great to use when wanting a simple database testing backend, is not the same as the Enterprise In-Memory Engine
  • wiredTiger is a storage engine which stores data on disk.
danger

MongoDB has stated that storage-engine ephemeralForTest is unstable and has been deprecated, it will be removed with mongodb 7.

In MMS there has been no observation of ephemeralForTest being unstable (aside from some missing features) and will continue to be the default until mongodb-memory-server changes to a version where ephemeralForTest is not present anymore.

With mongodb-memory-server 9.0.0, if mongodb 7.0.0 or higher is used, wiredTiger is the default engine.