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

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 = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'

Storage Engines supported by mongodb, see MongoDB Storage Engines.

Custom Explanation:

  • devnull is a storage engine which discards everything and cannot be read from.
  • 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
  • mmapv1 is storage engine which stores data on disk, was removed in mongodb 4.2
  • wiredTiger is a storage engine which stores data on disk.