fix(core): update

This commit is contained in:
Philipp Kunz 2022-05-17 17:16:12 +02:00
parent 9414dac380
commit 96cb2f2a3a
2 changed files with 14 additions and 6 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -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'
}

View File

@ -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<plugins.smartdata.IMongoDescriptor> {
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);
}
}