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
|
// INSTANCE
|
||||||
private _readyDeferred = plugins.smartpromise.defer();
|
private _readyDeferred = plugins.smartpromise.defer();
|
||||||
public readyPromise = this._readyDeferred.promise;
|
public readyPromise = this._readyDeferred.promise;
|
||||||
public mongod: plugins.mongoPlugin.MongoMemoryServer;
|
public mongoReplicaSet: plugins.mongoPlugin.MongoMemoryReplSet;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start(countArg: number = 4) {
|
||||||
this.mongod = await plugins.mongoPlugin.MongoMemoryServer.create();
|
this.mongoReplicaSet = await plugins.mongoPlugin.MongoMemoryReplSet.create({ replSet: { count: countArg } });
|
||||||
this._readyDeferred.resolve();
|
this._readyDeferred.resolve();
|
||||||
console.log('mongod started');
|
console.log(`mongoReplicaSet with ${countArg} replicas started.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor> {
|
public async getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor> {
|
||||||
await this.readyPromise;
|
await this.readyPromise;
|
||||||
return {
|
return {
|
||||||
mongoDbUrl: this.mongod.getUri(),
|
mongoDbUrl: this.mongoReplicaSet.getUri(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stop() {
|
public async stop() {
|
||||||
await this.mongod.stop(true);
|
await this.mongoReplicaSet.stop(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user