diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts new file mode 100644 index 0000000..d853ae1 --- /dev/null +++ b/ts/00_commitinfo_data.ts @@ -0,0 +1,8 @@ +/** + * autocreated commitinfo by @pushrocks/commitinfo + */ +export const commitinfo = { + name: '@pushrocks/smartmongo', + version: '1.0.9', + description: 'create a local mongodb for testing' +} diff --git a/ts/index.ts b/ts/index.ts index 329400d..36fe2d1 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -11,25 +11,25 @@ export class SmartMongo { // INSTANCE private _readyDeferred = plugins.smartpromise.defer(); public readyPromise = this._readyDeferred.promise; - public mongod: plugins.mongoPlugin.MongoMemoryServer; + public mongoReplicaSet: plugins.mongoPlugin.MongoMemoryReplSet; constructor() { } - public async start() { - this.mongod = await plugins.mongoPlugin.MongoMemoryServer.create(); + public async start(countArg: number = 4) { + this.mongoReplicaSet = await plugins.mongoPlugin.MongoMemoryReplSet.create({ replSet: { count: countArg } }); this._readyDeferred.resolve(); - console.log('mongod started'); + console.log(`mongoReplicaSet with ${countArg} replicas started.`); } public async getMongoDescriptor(): Promise { await this.readyPromise; return { - mongoDbUrl: this.mongod.getUri(), + mongoDbUrl: this.mongoReplicaSet.getUri(), } } public async stop() { - await this.mongod.stop(true); + await this.mongoReplicaSet.stop(true); } } \ No newline at end of file