4 Commits

Author SHA1 Message Date
5eed702631 2.0.7 2022-06-09 00:18:05 +02:00
ac5ce0346b fix(core): update 2022-06-09 00:18:05 +02:00
eabda34aca 2.0.6 2022-06-09 00:01:30 +02:00
0e41748da5 fix(core): update 2022-06-09 00:01:29 +02:00
4 changed files with 17 additions and 4 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@pushrocks/smartmongo", "name": "@pushrocks/smartmongo",
"version": "2.0.5", "version": "2.0.7",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@pushrocks/smartmongo", "name": "@pushrocks/smartmongo",
"version": "2.0.5", "version": "2.0.7",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@pushrocks/mongodump": "^1.0.7", "@pushrocks/mongodump": "^1.0.7",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartmongo", "name": "@pushrocks/smartmongo",
"version": "2.0.5", "version": "2.0.7",
"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",

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartmongo', name: '@pushrocks/smartmongo',
version: '2.0.5', version: '2.0.7',
description: 'create a local mongodb for testing' description: 'create a local mongodb for testing'
} }

View File

@@ -30,18 +30,31 @@ export class SmartMongo {
console.log(`@pushrocks/smartmongo version ${commitinfo.version}`); console.log(`@pushrocks/smartmongo version ${commitinfo.version}`);
} }
/**
* returns a mongo descriptor for modules like
* @pushrocks/smartfile.
*/
public async getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor> { public async getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor> {
await this.readyPromise; await this.readyPromise;
return { return {
mongoDbName: `smartmongo_testdatabase`,
mongoDbUrl: this.mongoReplicaSet.getUri(), mongoDbUrl: this.mongoReplicaSet.getUri(),
}; };
} }
/**
* stops the smartmongo instance
* and cleans up after itself
*/
public async stop() { public async stop() {
await this.mongoReplicaSet.stop(); await this.mongoReplicaSet.stop();
await this.mongoReplicaSet.cleanup(); await this.mongoReplicaSet.cleanup();
} }
/**
* like stop() but allows you to actually store
* the database on disk
*/
public async stopAndDumpToDir(dirArg: string, nameFunctionArg?: (doc: any) => string, emptyDirArg = true) { public async stopAndDumpToDir(dirArg: string, nameFunctionArg?: (doc: any) => string, emptyDirArg = true) {
const mongodumpInstance = new plugins.mongodump.MongoDump(); const mongodumpInstance = new plugins.mongodump.MongoDump();
const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(await this.getMongoDescriptor()); const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(await this.getMongoDescriptor());