@push.rocks/smartmongo 2.0.7
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 +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/index.d.ts +24 -0
- package/dist_ts/index.js +59 -0
- package/dist_ts/smartmongo.plugins.d.ts +7 -0
- package/dist_ts/smartmongo.plugins.js +10 -0
- package/license +19 -0
- package/npmextra.json +18 -0
- package/package.json +44 -0
- package/readme.md +39 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/index.ts +65 -0
- package/ts/smartmongo.plugins.ts +17 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autocreated commitinfo by @pushrocks/commitinfo
|
|
3
|
+
*/
|
|
4
|
+
export const commitinfo = {
|
|
5
|
+
name: '@pushrocks/smartmongo',
|
|
6
|
+
version: '2.0.7',
|
|
7
|
+
description: 'create a local mongodb for testing'
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx1QkFBdUI7SUFDN0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLG9DQUFvQztDQUNsRCxDQUFBIn0=
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as plugins from './smartmongo.plugins.js';
|
|
2
|
+
export declare class SmartMongo {
|
|
3
|
+
static createAndStart(replCountArg?: number): Promise<SmartMongo>;
|
|
4
|
+
private _readyDeferred;
|
|
5
|
+
readyPromise: Promise<unknown>;
|
|
6
|
+
mongoReplicaSet: plugins.mongoPlugin.MongoMemoryReplSet;
|
|
7
|
+
constructor();
|
|
8
|
+
start(countArg?: number): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* returns a mongo descriptor for modules like
|
|
11
|
+
* @pushrocks/smartfile.
|
|
12
|
+
*/
|
|
13
|
+
getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor>;
|
|
14
|
+
/**
|
|
15
|
+
* stops the smartmongo instance
|
|
16
|
+
* and cleans up after itself
|
|
17
|
+
*/
|
|
18
|
+
stop(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* like stop() but allows you to actually store
|
|
21
|
+
* the database on disk
|
|
22
|
+
*/
|
|
23
|
+
stopAndDumpToDir(dirArg: string, nameFunctionArg?: (doc: any) => string, emptyDirArg?: boolean): Promise<void>;
|
|
24
|
+
}
|
package/dist_ts/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { commitinfo } from './00_commitinfo_data.js';
|
|
2
|
+
import * as plugins from './smartmongo.plugins.js';
|
|
3
|
+
export class SmartMongo {
|
|
4
|
+
constructor() {
|
|
5
|
+
// INSTANCE
|
|
6
|
+
this._readyDeferred = plugins.smartpromise.defer();
|
|
7
|
+
this.readyPromise = this._readyDeferred.promise;
|
|
8
|
+
}
|
|
9
|
+
// STATIC
|
|
10
|
+
static async createAndStart(replCountArg = 1) {
|
|
11
|
+
const smartMongoInstance = new SmartMongo();
|
|
12
|
+
await smartMongoInstance.start(replCountArg);
|
|
13
|
+
return smartMongoInstance;
|
|
14
|
+
}
|
|
15
|
+
async start(countArg = 1) {
|
|
16
|
+
this.mongoReplicaSet = await plugins.mongoPlugin.MongoMemoryReplSet.create({
|
|
17
|
+
replSet: { count: countArg },
|
|
18
|
+
instanceOpts: [
|
|
19
|
+
{
|
|
20
|
+
storageEngine: 'wiredTiger',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
this._readyDeferred.resolve();
|
|
25
|
+
console.log(`mongoReplicaSet with ${countArg} replicas started.`);
|
|
26
|
+
console.log(`@pushrocks/smartmongo version ${commitinfo.version}`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* returns a mongo descriptor for modules like
|
|
30
|
+
* @pushrocks/smartfile.
|
|
31
|
+
*/
|
|
32
|
+
async getMongoDescriptor() {
|
|
33
|
+
await this.readyPromise;
|
|
34
|
+
return {
|
|
35
|
+
mongoDbName: `smartmongo_testdatabase`,
|
|
36
|
+
mongoDbUrl: this.mongoReplicaSet.getUri(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* stops the smartmongo instance
|
|
41
|
+
* and cleans up after itself
|
|
42
|
+
*/
|
|
43
|
+
async stop() {
|
|
44
|
+
await this.mongoReplicaSet.stop();
|
|
45
|
+
await this.mongoReplicaSet.cleanup();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* like stop() but allows you to actually store
|
|
49
|
+
* the database on disk
|
|
50
|
+
*/
|
|
51
|
+
async stopAndDumpToDir(dirArg, nameFunctionArg, emptyDirArg = true) {
|
|
52
|
+
const mongodumpInstance = new plugins.mongodump.MongoDump();
|
|
53
|
+
const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(await this.getMongoDescriptor());
|
|
54
|
+
await mongodumpTarget.dumpAllCollectionsToDir(dirArg, nameFunctionArg, emptyDirArg);
|
|
55
|
+
await mongodumpInstance.stop();
|
|
56
|
+
await this.stop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDckQsT0FBTyxLQUFLLE9BQU8sTUFBTSx5QkFBeUIsQ0FBQztBQUVuRCxNQUFNLE9BQU8sVUFBVTtJQWFyQjtRQUxBLFdBQVc7UUFDSCxtQkFBYyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDL0MsaUJBQVksR0FBRyxJQUFJLENBQUMsY0FBYyxDQUFDLE9BQU8sQ0FBQztJQUduQyxDQUFDO0lBWmhCLFNBQVM7SUFDRixNQUFNLENBQUMsS0FBSyxDQUFDLGNBQWMsQ0FBQyxlQUF1QixDQUFDO1FBQ3pELE1BQU0sa0JBQWtCLEdBQUcsSUFBSSxVQUFVLEVBQUUsQ0FBQztRQUM1QyxNQUFNLGtCQUFrQixDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQztRQUM3QyxPQUFPLGtCQUFrQixDQUFDO0lBQzVCLENBQUM7SUFTTSxLQUFLLENBQUMsS0FBSyxDQUFDLFdBQW1CLENBQUM7UUFDckMsSUFBSSxDQUFDLGVBQWUsR0FBRyxNQUFNLE9BQU8sQ0FBQyxXQUFXLENBQUMsa0JBQWtCLENBQUMsTUFBTSxDQUFDO1lBQ3pFLE9BQU8sRUFBRSxFQUFFLEtBQUssRUFBRSxRQUFRLEVBQUU7WUFDNUIsWUFBWSxFQUFFO2dCQUNaO29CQUNFLGFBQWEsRUFBRSxZQUFZO2lCQUM1QjthQUNGO1NBQ0YsQ0FBQyxDQUFDO1FBQ0gsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUM5QixPQUFPLENBQUMsR0FBRyxDQUFDLHdCQUF3QixRQUFRLG9CQUFvQixDQUFDLENBQUM7UUFDbEUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxpQ0FBaUMsVUFBVSxDQUFDLE9BQU8sRUFBRSxDQUFDLENBQUM7SUFDckUsQ0FBQztJQUVEOzs7T0FHRztJQUNJLEtBQUssQ0FBQyxrQkFBa0I7UUFDN0IsTUFBTSxJQUFJLENBQUMsWUFBWSxDQUFDO1FBQ3hCLE9BQU87WUFDTCxXQUFXLEVBQUUseUJBQXlCO1lBQ3RDLFVBQVUsRUFBRSxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sRUFBRTtTQUMxQyxDQUFDO0lBQ0osQ0FBQztJQUVEOzs7T0FHRztJQUNJLEtBQUssQ0FBQyxJQUFJO1FBQ2YsTUFBTSxJQUFJLENBQUMsZUFBZSxDQUFDLElBQUksRUFBRSxDQUFDO1FBQ2xDLE1BQU0sSUFBSSxDQUFDLGVBQWUsQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUN2QyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLGdCQUFnQixDQUFDLE1BQWMsRUFBRSxlQUFzQyxFQUFFLFdBQVcsR0FBRyxJQUFJO1FBQ3RHLE1BQU0saUJBQWlCLEdBQUcsSUFBSSxPQUFPLENBQUMsU0FBUyxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQzVELE1BQU0sZUFBZSxHQUFHLE1BQU0saUJBQWlCLENBQUMsK0JBQStCLENBQUMsTUFBTSxJQUFJLENBQUMsa0JBQWtCLEVBQUUsQ0FBQyxDQUFDO1FBQ2pILE1BQU0sZUFBZSxDQUFDLHVCQUF1QixDQUFDLE1BQU0sRUFBRSxlQUFlLEVBQUUsV0FBVyxDQUFDLENBQUM7UUFDcEYsTUFBTSxpQkFBaUIsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUMvQixNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNwQixDQUFDO0NBQ0YifQ==
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as mongodump from '@pushrocks/mongodump';
|
|
2
|
+
import * as smartdata from '@pushrocks/smartdata';
|
|
3
|
+
import * as smartpath from '@pushrocks/smartpath';
|
|
4
|
+
import * as smartpromise from '@pushrocks/smartpromise';
|
|
5
|
+
export { mongodump, smartdata, smartpath, smartpromise, };
|
|
6
|
+
import * as mongoPlugin from 'mongodb-memory-server';
|
|
7
|
+
export { mongoPlugin };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @pushrocks scope
|
|
2
|
+
import * as mongodump from '@pushrocks/mongodump';
|
|
3
|
+
import * as smartdata from '@pushrocks/smartdata';
|
|
4
|
+
import * as smartpath from '@pushrocks/smartpath';
|
|
5
|
+
import * as smartpromise from '@pushrocks/smartpromise';
|
|
6
|
+
export { mongodump, smartdata, smartpath, smartpromise, };
|
|
7
|
+
// thirdparty
|
|
8
|
+
import * as mongoPlugin from 'mongodb-memory-server';
|
|
9
|
+
export { mongoPlugin };
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRtb25nby5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRtb25nby5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1CQUFtQjtBQUNuQixPQUFPLEtBQUssU0FBUyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxTQUFTLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxLQUFLLFNBQVMsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRCxPQUFPLEtBQUssWUFBWSxNQUFNLHlCQUF5QixDQUFDO0FBRXhELE9BQU8sRUFDTCxTQUFTLEVBQ1QsU0FBUyxFQUNULFNBQVMsRUFDVCxZQUFZLEdBQ2IsQ0FBQTtBQUVELGFBQWE7QUFDYixPQUFPLEtBQUssV0FBVyxNQUFNLHVCQUF1QixDQUFDO0FBRXJELE9BQU8sRUFBRSxXQUFXLEVBQUUsQ0FBQyJ9
|
package/license
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2021 Lossless GmbH (hello@lossless.com)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/npmextra.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"gitzone": {
|
|
3
|
+
"projectType": "npm",
|
|
4
|
+
"module": {
|
|
5
|
+
"githost": "gitlab.com",
|
|
6
|
+
"gitscope": "pushrocks",
|
|
7
|
+
"gitrepo": "smartmongo",
|
|
8
|
+
"shortDescription": "create a local mongodb for testing",
|
|
9
|
+
"npmPackagename": "@pushrocks/smartmongo",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"projectDomain": "push.rocks"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"npmci": {
|
|
15
|
+
"npmGlobalTools": [],
|
|
16
|
+
"npmAccessLevel": "public"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@push.rocks/smartmongo",
|
|
3
|
+
"version": "2.0.7",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "create a local mongodb for testing",
|
|
6
|
+
"main": "dist_ts/index.js",
|
|
7
|
+
"typings": "dist_ts/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"author": "Lossless GmbH",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "(tstest test/ --web)",
|
|
13
|
+
"build": "(tsbuild --web --allowimplicitany)"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@gitzone/tsbuild": "^2.1.63",
|
|
17
|
+
"@gitzone/tsbundle": "^2.0.5",
|
|
18
|
+
"@gitzone/tstest": "^1.0.71",
|
|
19
|
+
"@pushrocks/tapbundle": "^5.0.3",
|
|
20
|
+
"@types/node": "^17.0.39"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@pushrocks/mongodump": "^1.0.7",
|
|
24
|
+
"@pushrocks/smartdata": "^5.0.3",
|
|
25
|
+
"@pushrocks/smartpath": "^5.0.5",
|
|
26
|
+
"@pushrocks/smartpromise": "^3.1.7",
|
|
27
|
+
"mongodb-memory-server": "^8.6.0"
|
|
28
|
+
},
|
|
29
|
+
"browserslist": [
|
|
30
|
+
"last 1 chrome versions"
|
|
31
|
+
],
|
|
32
|
+
"files": [
|
|
33
|
+
"ts/**/*",
|
|
34
|
+
"ts_web/**/*",
|
|
35
|
+
"dist/**/*",
|
|
36
|
+
"dist_*/**/*",
|
|
37
|
+
"dist_ts/**/*",
|
|
38
|
+
"dist_ts_web/**/*",
|
|
39
|
+
"assets/**/*",
|
|
40
|
+
"cli.js",
|
|
41
|
+
"npmextra.json",
|
|
42
|
+
"readme.md"
|
|
43
|
+
]
|
|
44
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @pushrocks/smartmongo
|
|
2
|
+
create a local mongodb for testing
|
|
3
|
+
|
|
4
|
+
## Availabililty and Links
|
|
5
|
+
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmongo)
|
|
6
|
+
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmongo)
|
|
7
|
+
* [github.com (source mirror)](https://github.com/pushrocks/smartmongo)
|
|
8
|
+
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmongo/)
|
|
9
|
+
|
|
10
|
+
## Status for master
|
|
11
|
+
|
|
12
|
+
Status Category | Status Badge
|
|
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)
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Use TypeScript for best in class intellisense
|
|
29
|
+
|
|
30
|
+
## Contribution
|
|
31
|
+
|
|
32
|
+
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
|
33
|
+
|
|
34
|
+
For further information read the linked docs at the top of this readme.
|
|
35
|
+
|
|
36
|
+
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
|
37
|
+
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
38
|
+
|
|
39
|
+
[](https://maintainedby.lossless.com)
|
package/ts/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { commitinfo } from './00_commitinfo_data.js';
|
|
2
|
+
import * as plugins from './smartmongo.plugins.js';
|
|
3
|
+
|
|
4
|
+
export class SmartMongo {
|
|
5
|
+
// STATIC
|
|
6
|
+
public static async createAndStart(replCountArg: number = 1) {
|
|
7
|
+
const smartMongoInstance = new SmartMongo();
|
|
8
|
+
await smartMongoInstance.start(replCountArg);
|
|
9
|
+
return smartMongoInstance;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// INSTANCE
|
|
13
|
+
private _readyDeferred = plugins.smartpromise.defer();
|
|
14
|
+
public readyPromise = this._readyDeferred.promise;
|
|
15
|
+
public mongoReplicaSet: plugins.mongoPlugin.MongoMemoryReplSet;
|
|
16
|
+
|
|
17
|
+
constructor() {}
|
|
18
|
+
|
|
19
|
+
public async start(countArg: number = 1) {
|
|
20
|
+
this.mongoReplicaSet = await plugins.mongoPlugin.MongoMemoryReplSet.create({
|
|
21
|
+
replSet: { count: countArg },
|
|
22
|
+
instanceOpts: [
|
|
23
|
+
{
|
|
24
|
+
storageEngine: 'wiredTiger',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
this._readyDeferred.resolve();
|
|
29
|
+
console.log(`mongoReplicaSet with ${countArg} replicas started.`);
|
|
30
|
+
console.log(`@pushrocks/smartmongo version ${commitinfo.version}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* returns a mongo descriptor for modules like
|
|
35
|
+
* @pushrocks/smartfile.
|
|
36
|
+
*/
|
|
37
|
+
public async getMongoDescriptor(): Promise<plugins.smartdata.IMongoDescriptor> {
|
|
38
|
+
await this.readyPromise;
|
|
39
|
+
return {
|
|
40
|
+
mongoDbName: `smartmongo_testdatabase`,
|
|
41
|
+
mongoDbUrl: this.mongoReplicaSet.getUri(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* stops the smartmongo instance
|
|
47
|
+
* and cleans up after itself
|
|
48
|
+
*/
|
|
49
|
+
public async stop() {
|
|
50
|
+
await this.mongoReplicaSet.stop();
|
|
51
|
+
await this.mongoReplicaSet.cleanup();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* like stop() but allows you to actually store
|
|
56
|
+
* the database on disk
|
|
57
|
+
*/
|
|
58
|
+
public async stopAndDumpToDir(dirArg: string, nameFunctionArg?: (doc: any) => string, emptyDirArg = true) {
|
|
59
|
+
const mongodumpInstance = new plugins.mongodump.MongoDump();
|
|
60
|
+
const mongodumpTarget = await mongodumpInstance.addMongoTargetByMongoDescriptor(await this.getMongoDescriptor());
|
|
61
|
+
await mongodumpTarget.dumpAllCollectionsToDir(dirArg, nameFunctionArg, emptyDirArg);
|
|
62
|
+
await mongodumpInstance.stop();
|
|
63
|
+
await this.stop();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @pushrocks scope
|
|
2
|
+
import * as mongodump from '@pushrocks/mongodump';
|
|
3
|
+
import * as smartdata from '@pushrocks/smartdata';
|
|
4
|
+
import * as smartpath from '@pushrocks/smartpath';
|
|
5
|
+
import * as smartpromise from '@pushrocks/smartpromise';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
mongodump,
|
|
9
|
+
smartdata,
|
|
10
|
+
smartpath,
|
|
11
|
+
smartpromise,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// thirdparty
|
|
15
|
+
import * as mongoPlugin from 'mongodb-memory-server';
|
|
16
|
+
|
|
17
|
+
export { mongoPlugin };
|