@push.rocks/smartmongo 2.0.7 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.d.ts +1 -1
- package/dist_ts/00_commitinfo_data.js +5 -5
- package/dist_ts/index.js +6 -6
- package/dist_ts/smartmongo.plugins.d.ts +5 -5
- package/dist_ts/smartmongo.plugins.js +6 -6
- package/npmextra.json +17 -5
- package/package.json +33 -17
- package/readme.hints.md +1 -0
- package/readme.md +93 -29
- package/ts/00_commitinfo_data.ts +4 -4
- package/ts/index.ts +8 -2
- package/ts/smartmongo.plugins.ts +5 -10
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* autocreated commitinfo by @
|
|
2
|
+
* autocreated commitinfo by @push.rocks/commitinfo
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
|
-
name: '@
|
|
6
|
-
version: '2.0.
|
|
7
|
-
description: '
|
|
5
|
+
name: '@push.rocks/smartmongo',
|
|
6
|
+
version: '2.0.11',
|
|
7
|
+
description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG1GQUFtRjtDQUNqRyxDQUFBIn0=
|
package/dist_ts/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { commitinfo } from './00_commitinfo_data.js';
|
|
2
2
|
import * as plugins from './smartmongo.plugins.js';
|
|
3
3
|
export class SmartMongo {
|
|
4
|
-
constructor() {
|
|
5
|
-
// INSTANCE
|
|
6
|
-
this._readyDeferred = plugins.smartpromise.defer();
|
|
7
|
-
this.readyPromise = this._readyDeferred.promise;
|
|
8
|
-
}
|
|
9
4
|
// STATIC
|
|
10
5
|
static async createAndStart(replCountArg = 1) {
|
|
11
6
|
const smartMongoInstance = new SmartMongo();
|
|
12
7
|
await smartMongoInstance.start(replCountArg);
|
|
13
8
|
return smartMongoInstance;
|
|
14
9
|
}
|
|
10
|
+
constructor() {
|
|
11
|
+
// INSTANCE
|
|
12
|
+
this._readyDeferred = plugins.smartpromise.defer();
|
|
13
|
+
this.readyPromise = this._readyDeferred.promise;
|
|
14
|
+
}
|
|
15
15
|
async start(countArg = 1) {
|
|
16
16
|
this.mongoReplicaSet = await plugins.mongoPlugin.MongoMemoryReplSet.create({
|
|
17
17
|
replSet: { count: countArg },
|
|
@@ -56,4 +56,4 @@ export class SmartMongo {
|
|
|
56
56
|
await this.stop();
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDckQsT0FBTyxLQUFLLE9BQU8sTUFBTSx5QkFBeUIsQ0FBQztBQUVuRCxNQUFNLE9BQU8sVUFBVTtJQUNyQixTQUFTO0lBQ0YsTUFBTSxDQUFDLEtBQUssQ0FBQyxjQUFjLENBQUMsZUFBdUIsQ0FBQztRQUN6RCxNQUFNLGtCQUFrQixHQUFHLElBQUksVUFBVSxFQUFFLENBQUM7UUFDNUMsTUFBTSxrQkFBa0IsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDN0MsT0FBTyxrQkFBa0IsQ0FBQztJQUM1QixDQUFDO0lBT0Q7UUFMQSxXQUFXO1FBQ0gsbUJBQWMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQy9DLGlCQUFZLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLENBQUM7SUFHbkMsQ0FBQztJQUVULEtBQUssQ0FBQyxLQUFLLENBQUMsV0FBbUIsQ0FBQztRQUNyQyxJQUFJLENBQUMsZUFBZSxHQUFHLE1BQU0sT0FBTyxDQUFDLFdBQVcsQ0FBQyxrQkFBa0IsQ0FBQyxNQUFNLENBQUM7WUFDekUsT0FBTyxFQUFFLEVBQUUsS0FBSyxFQUFFLFFBQVEsRUFBRTtZQUM1QixZQUFZLEVBQUU7Z0JBQ1o7b0JBQ0UsYUFBYSxFQUFFLFlBQVk7aUJBQzVCO2FBQ0Y7U0FDRixDQUFDLENBQUM7UUFDSCxJQUFJLENBQUMsY0FBYyxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQzlCLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLFFBQVEsb0JBQW9CLENBQUMsQ0FBQztRQUNsRSxPQUFPLENBQUMsR0FBRyxDQUFDLGlDQUFpQyxVQUFVLENBQUMsT0FBTyxFQUFFLENBQUMsQ0FBQztJQUNyRSxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLGtCQUFrQjtRQUM3QixNQUFNLElBQUksQ0FBQyxZQUFZLENBQUM7UUFDeEIsT0FBTztZQUNMLFdBQVcsRUFBRSx5QkFBeUI7WUFDdEMsVUFBVSxFQUFFLElBQUksQ0FBQyxlQUFlLENBQUMsTUFBTSxFQUFFO1NBQzFDLENBQUM7SUFDSixDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLElBQUk7UUFDZixNQUFNLElBQUksQ0FBQyxlQUFlLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbEMsTUFBTSxJQUFJLENBQUMsZUFBZSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ3ZDLENBQUM7SUFFRDs7O09BR0c7SUFDSSxLQUFLLENBQUMsZ0JBQWdCLENBQzNCLE1BQWMsRUFDZCxlQUFzQyxFQUN0QyxXQUFXLEdBQUcsSUFBSTtRQUVsQixNQUFNLGlCQUFpQixHQUFHLElBQUksT0FBTyxDQUFDLFNBQVMsQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUM1RCxNQUFNLGVBQWUsR0FBRyxNQUFNLGlCQUFpQixDQUFDLCtCQUErQixDQUM3RSxNQUFNLElBQUksQ0FBQyxrQkFBa0IsRUFBRSxDQUNoQyxDQUFDO1FBQ0YsTUFBTSxlQUFlLENBQUMsdUJBQXVCLENBQUMsTUFBTSxFQUFFLGVBQWUsRUFBRSxXQUFXLENBQUMsQ0FBQztRQUNwRixNQUFNLGlCQUFpQixDQUFDLElBQUksRUFBRSxDQUFDO1FBQy9CLE1BQU0sSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDO0lBQ3BCLENBQUM7Q0FDRiJ9
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as mongodump from '@
|
|
2
|
-
import * as smartdata from '@
|
|
3
|
-
import * as smartpath from '@
|
|
4
|
-
import * as smartpromise from '@
|
|
5
|
-
export { mongodump, smartdata, smartpath, smartpromise
|
|
1
|
+
import * as mongodump from '@push.rocks/mongodump';
|
|
2
|
+
import * as smartdata from '@push.rocks/smartdata';
|
|
3
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
4
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
5
|
+
export { mongodump, smartdata, smartpath, smartpromise };
|
|
6
6
|
import * as mongoPlugin from 'mongodb-memory-server';
|
|
7
7
|
export { mongoPlugin };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @pushrocks scope
|
|
2
|
-
import * as mongodump from '@
|
|
3
|
-
import * as smartdata from '@
|
|
4
|
-
import * as smartpath from '@
|
|
5
|
-
import * as smartpromise from '@
|
|
6
|
-
export { mongodump, smartdata, smartpath, smartpromise
|
|
2
|
+
import * as mongodump from '@push.rocks/mongodump';
|
|
3
|
+
import * as smartdata from '@push.rocks/smartdata';
|
|
4
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
5
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
6
|
+
export { mongodump, smartdata, smartpath, smartpromise };
|
|
7
7
|
// thirdparty
|
|
8
8
|
import * as mongoPlugin from 'mongodb-memory-server';
|
|
9
9
|
export { mongoPlugin };
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRtb25nby5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRtb25nby5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLFNBQVMsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssWUFBWSxNQUFNLDBCQUEwQixDQUFDO0FBRXpELE9BQU8sRUFBRSxTQUFTLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsQ0FBQztBQUV6RCxhQUFhO0FBQ2IsT0FBTyxLQUFLLFdBQVcsTUFBTSx1QkFBdUIsQ0FBQztBQUVyRCxPQUFPLEVBQUUsV0FBVyxFQUFFLENBQUMifQ==
|
package/npmextra.json
CHANGED
|
@@ -2,17 +2,29 @@
|
|
|
2
2
|
"gitzone": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
|
-
"githost": "
|
|
6
|
-
"gitscope": "
|
|
5
|
+
"githost": "code.foss.global",
|
|
6
|
+
"gitscope": "push.rocks",
|
|
7
7
|
"gitrepo": "smartmongo",
|
|
8
|
-
"
|
|
9
|
-
"npmPackagename": "@
|
|
8
|
+
"description": "A module for creating and managing a local MongoDB instance for testing purposes.",
|
|
9
|
+
"npmPackagename": "@push.rocks/smartmongo",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"projectDomain": "push.rocks"
|
|
11
|
+
"projectDomain": "push.rocks",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mongodb",
|
|
14
|
+
"testing",
|
|
15
|
+
"local database",
|
|
16
|
+
"replica set",
|
|
17
|
+
"memory server",
|
|
18
|
+
"database management",
|
|
19
|
+
"typescript"
|
|
20
|
+
]
|
|
12
21
|
}
|
|
13
22
|
},
|
|
14
23
|
"npmci": {
|
|
15
24
|
"npmGlobalTools": [],
|
|
16
25
|
"npmAccessLevel": "public"
|
|
26
|
+
},
|
|
27
|
+
"tsdoc": {
|
|
28
|
+
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
17
29
|
}
|
|
18
30
|
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartmongo",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A module for creating and managing a local MongoDB instance for testing purposes.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
7
7
|
"typings": "dist_ts/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "Lossless GmbH",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "(tstest test/ --web)",
|
|
13
|
-
"build": "(tsbuild --web --allowimplicitany)"
|
|
14
|
-
},
|
|
15
11
|
"devDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
12
|
+
"@git.zone/tsbuild": "^2.1.66",
|
|
13
|
+
"@git.zone/tsbundle": "^2.0.8",
|
|
14
|
+
"@git.zone/tsrun": "^1.2.44",
|
|
15
|
+
"@git.zone/tstest": "^1.0.77",
|
|
16
|
+
"@push.rocks/tapbundle": "^5.0.12",
|
|
17
|
+
"@types/node": "^22.14.0"
|
|
21
18
|
},
|
|
22
19
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"mongodb-memory-server": "^
|
|
20
|
+
"@push.rocks/mongodump": "^1.0.7",
|
|
21
|
+
"@push.rocks/smartdata": "^5.0.23",
|
|
22
|
+
"@push.rocks/smartpath": "^5.0.11",
|
|
23
|
+
"@push.rocks/smartpromise": "^4.0.3",
|
|
24
|
+
"mongodb-memory-server": "^10.1.4"
|
|
28
25
|
},
|
|
29
26
|
"browserslist": [
|
|
30
27
|
"last 1 chrome versions"
|
|
@@ -40,5 +37,24 @@
|
|
|
40
37
|
"cli.js",
|
|
41
38
|
"npmextra.json",
|
|
42
39
|
"readme.md"
|
|
43
|
-
]
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"mongodb",
|
|
43
|
+
"testing",
|
|
44
|
+
"local database",
|
|
45
|
+
"replica set",
|
|
46
|
+
"memory server",
|
|
47
|
+
"database management",
|
|
48
|
+
"typescript"
|
|
49
|
+
],
|
|
50
|
+
"homepage": "https://code.foss.global/push.rocks/smartmongo",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://code.foss.global/push.rocks/smartmongo.git"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"test": "(tstest test/ --web)",
|
|
57
|
+
"build": "(tsbuild --web --allowimplicitany)",
|
|
58
|
+
"buildDocs": "tsdoc"
|
|
59
|
+
}
|
|
44
60
|
}
|
package/readme.hints.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/readme.md
CHANGED
|
@@ -1,39 +1,103 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @push.rocks/smartmongo
|
|
2
2
|
create a local mongodb for testing
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-- | --
|
|
14
|
-
GitLab Pipelines | [](https://lossless.cloud)
|
|
15
|
-
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
16
|
-
npm | [](https://lossless.cloud)
|
|
17
|
-
Snyk | [](https://lossless.cloud)
|
|
18
|
-
TypeScript Support | [](https://lossless.cloud)
|
|
19
|
-
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
20
|
-
Code Style | [](https://lossless.cloud)
|
|
21
|
-
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
22
|
-
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
23
|
-
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
24
|
-
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
4
|
+
## Install
|
|
5
|
+
|
|
6
|
+
To start using @push.rocks/smartmongo in your project, you first need to install it via npm. You can do this by running the following command in your terminal:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @push.rocks/smartmongo --save-dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This will add `@push.rocks/smartmongo` as a development dependency to your project because it's typically used for testing purposes.
|
|
25
13
|
|
|
26
14
|
## Usage
|
|
27
15
|
|
|
28
|
-
|
|
16
|
+
The `@push.rocks/smartmongo` package provides a convenient way to spin up a local MongoDB instance, primarily for testing purposes. It's designed to simplify the process of configuring and managing a MongoDB replica set during development or in CI/CD pipelines. Below, we present a comprehensive guide on how to utilize the full feature set of this module, employing ESM syntax and TypeScript.
|
|
17
|
+
|
|
18
|
+
### Setting Up
|
|
19
|
+
|
|
20
|
+
To get started, you must first import the `SmartMongo` class from the package. This class is responsible for handling the MongoDB instances.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { SmartMongo } from '@push.rocks/smartmongo';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Creating and Starting a MongoDB Instance
|
|
27
|
+
|
|
28
|
+
With `SmartMongo`, you can easily create and start a MongoDB replica set. You can specify the number of replica instances; however, if not specified, it defaults to 1.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
async function setupMongoDB() {
|
|
32
|
+
const smartMongoInstance = await SmartMongo.createAndStart(1); // Number of replicas is optional
|
|
33
|
+
return smartMongoInstance;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const myDbInstance = await setupMongoDB();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
After invoking `createAndStart`, an instance of MongoDB is spun up and is ready for use. The `createAndStart` function returns a `SmartMongo` instance which can be interacted with for further operations.
|
|
40
|
+
|
|
41
|
+
### Accessing MongoDB Connection Information
|
|
42
|
+
|
|
43
|
+
After instantiation, you might want to connect your application or test suite to the MongoDB instance. The `getMongoDescriptor` method facilitates this by providing essential connection details.
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const mongoDescriptor = await myDbInstance.getMongoDescriptor();
|
|
47
|
+
console.log(mongoDescriptor.mongoDbUrl); // Use this URL to connect with Mongoose or MongoDB clients.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Stopping and Cleaning Up
|
|
51
|
+
|
|
52
|
+
Once your tests have completed or you're done using the MongoDB instance, it’s crucial to properly stop and clean up the resources. `@push.rocks/smartmongo` provides two methods for this purpose:
|
|
53
|
+
|
|
54
|
+
1. **stop()**: Stops the MongoDB instance without persisting any data.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
await myDbInstance.stop();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. **stopAndDumpToDir(dirPath)**: Stops the MongoDB instance and persists the data to the specified directory. This is useful if you need to examine the data post-test or reuse it in subsequent runs.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
await myDbInstance.stopAndDumpToDir('./path/to/dump');
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Advanced Usage
|
|
67
|
+
|
|
68
|
+
`@push.rocks/smartmongo` also provides advanced features for dumping the database and configuring MongoDB replica sets. These features can be particularly useful for complex testing scenarios or when specific MongoDB behaviors need to be emulated.
|
|
69
|
+
|
|
70
|
+
#### Dumping Data
|
|
71
|
+
|
|
72
|
+
To dump the MongoDB data for inspection or backup purposes, use the `stopAndDumpToDir` method. This method optionally takes a function to customize the naming scheme of the dumped files based on the document content.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
await myDbInstance.stopAndDumpToDir('./path/to/dump', (doc) => {
|
|
76
|
+
return `customNameBasedOnDoc-${doc._id}.bson`;
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Using `@push.rocks/smartmongo` significantly simplifies the process of managing MongoDB instances for local testing environments. It abstracts away the complexity of starting, operating, and tearing down MongoDB replica sets, allowing developers to focus on building and testing their applications.
|
|
81
|
+
|
|
82
|
+
### Conclusion
|
|
83
|
+
|
|
84
|
+
`@push.rocks/smartmongo` serves as a powerful tool in a developer's arsenal for efficiently configuring, running, and managing MongoDB instances in testing scenarios. By following the above guide, developers can leverage MongoDB in their projects with minimal setup and gain valuable insights into their applications' data interactions in a controlled and reproducible environment.
|
|
85
|
+
|
|
86
|
+
## License and Legal Information
|
|
87
|
+
|
|
88
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
89
|
+
|
|
90
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
91
|
+
|
|
92
|
+
### Trademarks
|
|
29
93
|
|
|
30
|
-
|
|
94
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
|
31
95
|
|
|
32
|
-
|
|
96
|
+
### Company Information
|
|
33
97
|
|
|
34
|
-
|
|
98
|
+
Task Venture Capital GmbH
|
|
99
|
+
Registered at District court Bremen HRB 35230 HB, Germany
|
|
35
100
|
|
|
36
|
-
|
|
37
|
-
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
101
|
+
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
38
102
|
|
|
39
|
-
|
|
103
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* autocreated commitinfo by @
|
|
2
|
+
* autocreated commitinfo by @push.rocks/commitinfo
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
|
-
name: '@
|
|
6
|
-
version: '2.0.
|
|
7
|
-
description: '
|
|
5
|
+
name: '@push.rocks/smartmongo',
|
|
6
|
+
version: '2.0.11',
|
|
7
|
+
description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
|
|
8
8
|
}
|
package/ts/index.ts
CHANGED
|
@@ -55,9 +55,15 @@ export class SmartMongo {
|
|
|
55
55
|
* like stop() but allows you to actually store
|
|
56
56
|
* the database on disk
|
|
57
57
|
*/
|
|
58
|
-
public async stopAndDumpToDir(
|
|
58
|
+
public async stopAndDumpToDir(
|
|
59
|
+
dirArg: string,
|
|
60
|
+
nameFunctionArg?: (doc: any) => string,
|
|
61
|
+
emptyDirArg = true
|
|
62
|
+
) {
|
|
59
63
|
const mongodumpInstance = new plugins.mongodump.MongoDump();
|
|
60
|
-
const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(
|
|
64
|
+
const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(
|
|
65
|
+
await this.getMongoDescriptor()
|
|
66
|
+
);
|
|
61
67
|
await mongodumpTarget.dumpAllCollectionsToDir(dirArg, nameFunctionArg, emptyDirArg);
|
|
62
68
|
await mongodumpInstance.stop();
|
|
63
69
|
await this.stop();
|
package/ts/smartmongo.plugins.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
// @pushrocks scope
|
|
2
|
-
import * as mongodump from '@
|
|
3
|
-
import * as smartdata from '@
|
|
4
|
-
import * as smartpath from '@
|
|
5
|
-
import * as smartpromise from '@
|
|
2
|
+
import * as mongodump from '@push.rocks/mongodump';
|
|
3
|
+
import * as smartdata from '@push.rocks/smartdata';
|
|
4
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
5
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
mongodump,
|
|
9
|
-
smartdata,
|
|
10
|
-
smartpath,
|
|
11
|
-
smartpromise,
|
|
12
|
-
}
|
|
7
|
+
export { mongodump, smartdata, smartpath, smartpromise };
|
|
13
8
|
|
|
14
9
|
// thirdparty
|
|
15
10
|
import * as mongoPlugin from 'mongodb-memory-server';
|