fix(core): update
This commit is contained in:
parent
9414dac380
commit
96cb2f2a3a
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal 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'
|
||||
}
|
12
ts/index.ts
12
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<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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user