Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e01d09e40a | |||
| 96cb2f2a3a | |||
| 9414dac380 | |||
| 160e350b82 | |||
| 457de52134 | |||
| 997a662d63 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmongo",
|
"name": "@pushrocks/smartmongo",
|
||||||
"version": "1.0.6",
|
"version": "1.0.9",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartmongo",
|
"name": "@pushrocks/smartmongo",
|
||||||
"version": "1.0.6",
|
"version": "1.0.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdata": "^4.0.27",
|
"@pushrocks/smartdata": "^4.0.27",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmongo",
|
"name": "@pushrocks/smartmongo",
|
||||||
"version": "1.0.6",
|
"version": "1.0.9",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "create a local mongodb for testing",
|
"description": "create a local mongodb for testing",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import * as smartmongo from '../ts/index';
|
|||||||
let smartmongoInstance: smartmongo.SmartMongo;
|
let smartmongoInstance: smartmongo.SmartMongo;
|
||||||
|
|
||||||
tap.test('should create a mongo instance', async () => {
|
tap.test('should create a mongo instance', async () => {
|
||||||
smartmongoInstance = await smartmongo.SmartMongo.createAndInit();
|
smartmongoInstance = await smartmongo.SmartMongo.createAndStart();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should stop the instance', async () => {
|
tap.test('should stop the instance', async () => {
|
||||||
|
|||||||
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() {
|
||||||
this.mongod.stop();
|
await this.mongoReplicaSet.stop(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user