From 96cb2f2a3ab97f32cf8d3fa164da9dedcd2973f8 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 17 May 2022 17:16:12 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 8 ++++++++ ts/index.ts | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 ts/00_commitinfo_data.ts 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