/// import { ChildProcess } from 'child_process'; import * as tmp from 'tmp'; import MongoInstance from './util/MongoInstance'; import { MongoBinaryOpts } from './util/MongoBinary'; import { MongoMemoryInstancePropT, StorageEngineT, SpawnOptions } from './types'; /** * Starting Options */ export interface MongoMemoryServerOptsT { instance?: MongoMemoryInstancePropT; binary?: MongoBinaryOpts; spawn?: SpawnOptions; autoStart?: boolean; } /** * Data used by _startUpInstance's "data" variable */ export interface StartupInstanceData { port: number; dbPath?: string; dbName: string; ip: string; uri?: string; storageEngine: StorageEngineT; replSet?: string; tmpDir?: tmp.DirResult; } /** * Information about the currently running instance */ export interface MongoInstanceDataT extends StartupInstanceData { dbPath: string; uri: string; instance: MongoInstance; childProcess?: ChildProcess; } export default class MongoMemoryServer { runningInstance: Promise | null; instanceInfoSync: MongoInstanceDataT | null; opts: MongoMemoryServerOptsT; /** * Create an Mongo-Memory-Sever Instance * * Note: because of JavaScript limitations, autoStart cannot be awaited here, use ".create" for async/await ability * @param opts Mongo-Memory-Sever Options */ constructor(opts?: MongoMemoryServerOptsT); /** * Create an Mongo-Memory-Sever Instance that can be awaited * @param opts Mongo-Memory-Sever Options */ static create(opts?: MongoMemoryServerOptsT): Promise; /** * Start the in-memory Instance * (when options.autoStart is true, this already got called) */ start(): Promise; /** * Internal Function to start an instance * @private */ _startUpInstance(): Promise; /** * Stop the current In-Memory Instance */ stop(): Promise; /** * Get Information about the currently running instance, if it is not running it returns "false" */ getInstanceInfo(): MongoInstanceDataT | false; /** * Ensure that the instance is running * -> throws if instance cannot be started */ ensureInstance(): Promise; /** * Get a mongodb-URI for a different DataBase * @param otherDbName Set this to "true" to generate a random DataBase name, otherwise a string to specify a DataBase name */ getUri(otherDbName?: string | boolean): Promise; /** * Get a mongodb-URI for a different DataBase * @param otherDbName Set this to "true" to generate a random DataBase name, otherwise a string to specify a DataBase name * @deprecated */ getConnectionString(otherDbName?: string | boolean): Promise; /** * Get the Port of the currently running Instance * Note: calls "ensureInstance" */ getPort(): Promise; /** * Get the DB-Path of the currently running Instance * Note: calls "ensureInstance" */ getDbPath(): Promise; /** * Get the DB-Name of the currently running Instance * Note: calls "ensureInstance" */ getDbName(): Promise; } //# sourceMappingURL=MongoMemoryServer.d.ts.map