Skip to content

Commit d1e4b53

Browse files
mathieugnodkz
authored andcommitted
fix(ReplSet): typescript definitions ReplSetOpts.dbName is optional
* ReplSetOpts.dbName is optional * Fix uses of dbName * fix: better ts definitions
1 parent 983d9a3 commit d1e4b53

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
},
5959
"scripts": {
6060
"test": "lerna run test --stream",
61+
"lint": "lerna run lint --stream",
6162
"watch": "yarn test --watchAll",
6263
"build": "tsc --build tsconfig.build.json",
6364
"release": "yarn build && lerna publish",

packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
* @property {boolean} auth enable auth; (default: false)
1919
* @property {string[]} args additional command line args passed to `mongod`
2020
* @property {number} count number of `mongod` servers to start (default: 1)
21-
* @property {string} dbName database name used in connection string
21+
* @property {string} dbName database name used in connection string (default: uuid)
2222
* @property {string} ip bind to all IP addresses specify `::,0.0.0.0`; (default '127.0.0.1')
2323
* @property {string} name replSet name (default: 'testset')
2424
* @property {number} oplogSize oplog size (in MB); (default: 1)
@@ -28,7 +28,7 @@ export interface ReplSetOpts {
2828
auth?: boolean;
2929
args?: string[];
3030
count?: number;
31-
dbName: string;
31+
dbName?: string;
3232
ip?: string;
3333
name?: string;
3434
oplogSize?: number;
@@ -46,23 +46,30 @@ export interface MongoMemoryReplSetConfigSettingsT {
4646
}
4747

4848
export interface MongoMemoryReplSetOptsT {
49-
instanceOpts: MongoMemoryInstancePropBaseT[];
50-
binary: MongoBinaryOpts;
51-
replSet: ReplSetOpts;
49+
instanceOpts?: MongoMemoryInstancePropBaseT[];
50+
binary?: MongoBinaryOpts;
51+
replSet?: ReplSetOpts;
5252
autoStart?: boolean;
5353
debug?: boolean;
5454
}
5555

5656
export default class MongoMemoryReplSet extends EventEmitter {
5757
servers: MongoMemoryServer[] = [];
58-
opts: MongoMemoryReplSetOptsT;
58+
opts: {
59+
instanceOpts: MongoMemoryInstancePropBaseT[];
60+
binary: MongoBinaryOpts;
61+
replSet: Required<ReplSetOpts>;
62+
debug: boolean;
63+
autoStart?: boolean;
64+
};
65+
5966
debug: DebugFn;
6067
_state: 'init' | 'running' | 'stopped';
6168
admin?: mongodb.Admin;
6269

63-
constructor(opts: Partial<MongoMemoryReplSetOptsT> = {}) {
70+
constructor(opts: MongoMemoryReplSetOptsT = {}) {
6471
super();
65-
const replSetDefaults: ReplSetOpts = {
72+
const replSetDefaults: Required<ReplSetOpts> = {
6673
auth: false,
6774
args: [],
6875
name: 'testset',
@@ -72,6 +79,7 @@ export default class MongoMemoryReplSet extends EventEmitter {
7279
oplogSize: 1,
7380
spawn: {},
7481
storageEngine: 'ephemeralForTest',
82+
configSettings: {},
7583
};
7684
this._state = 'stopped';
7785
this.opts = {

0 commit comments

Comments
 (0)