@biorate/mongodb 0.26.0
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/CHANGELOG.md +17 -0
- package/LICENSE +22 -0
- package/README.md +100 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/src/errors.js +11 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.js +83 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces.js +3 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.ts +1 -0
- package/package.json +37 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +152 -0
- package/src/interfaces.ts +11 -0
- package/tests/__mocks__/index.ts +36 -0
- package/tests/__mocks__/models/index.ts +1 -0
- package/tests/__mocks__/models/test.ts +18 -0
- package/tests/__snapshots__/index.spec.ts.snap +21 -0
- package/tests/index.spec.ts +37 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +6 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
|
+
|
6
|
+
# [0.26.0](https://github.com/biorate/core/compare/v0.25.0...v0.26.0) (2022-04-25)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* keyword added ([f5314a9](https://github.com/biorate/core/commit/f5314a93b30fa6f25f1e59749560c9f562d52798))
|
12
|
+
* **mongodb:** props incapsulation ([ae65939](https://github.com/biorate/core/commit/ae659399a8f0632aa1d4551615674bf9439c0ea0))
|
13
|
+
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* **mongodb:** module added ([d55b125](https://github.com/biorate/core/commit/d55b125c4f1e2f6e8804f5996a6ca4510081136e))
|
package/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021-present Leonid Levkin (llevkin)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Mongodb
|
2
|
+
|
3
|
+
Mongodb ORM connector based on mongoose and typegoose
|
4
|
+
|
5
|
+
### Examples:
|
6
|
+
|
7
|
+
```ts
|
8
|
+
import { inject, container, Types, Core } from '@biorate/inversion';
|
9
|
+
import { IConfig, Config } from '@biorate/config';
|
10
|
+
import {
|
11
|
+
Severity,
|
12
|
+
modelOptions,
|
13
|
+
Prop,
|
14
|
+
MongoDBConnector,
|
15
|
+
IMongoDBConnector,
|
16
|
+
model,
|
17
|
+
ReturnModelType,
|
18
|
+
} from '@biorate/mongodb';
|
19
|
+
|
20
|
+
// Define models
|
21
|
+
@modelOptions({
|
22
|
+
options: {
|
23
|
+
allowMixed: Severity.ALLOW,
|
24
|
+
},
|
25
|
+
schemaOptions: { collection: 'test', versionKey: false },
|
26
|
+
})
|
27
|
+
export class TestModel {
|
28
|
+
@Prop()
|
29
|
+
firstName: string;
|
30
|
+
|
31
|
+
@Prop()
|
32
|
+
lastName: string;
|
33
|
+
|
34
|
+
@Prop()
|
35
|
+
age: number;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Define root
|
39
|
+
export class Root extends Core() {
|
40
|
+
@inject(MongoDBConnector) public connector: IMongoDBConnector;
|
41
|
+
@model(TestModel) public test: ReturnModelType<typeof TestModel>;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Bind dependencies
|
45
|
+
container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
|
46
|
+
container.bind<IMongoDBConnector>(MongoDBConnector).toSelf().inSingletonScope();
|
47
|
+
container.bind<Root>(Root).toSelf().inSingletonScope();
|
48
|
+
|
49
|
+
// Configure
|
50
|
+
container.get<IConfig>(Types.Config).merge({
|
51
|
+
MongoDB: [
|
52
|
+
{
|
53
|
+
name: 'connection',
|
54
|
+
host: 'mongodb://localhost:27017/',
|
55
|
+
options: {
|
56
|
+
useNewUrlParser: true,
|
57
|
+
useUnifiedTopology: true,
|
58
|
+
dbName: 'test',
|
59
|
+
},
|
60
|
+
},
|
61
|
+
],
|
62
|
+
});
|
63
|
+
|
64
|
+
(async () => {
|
65
|
+
const root = container.get<Root>(Root);
|
66
|
+
await root.$run();
|
67
|
+
await root.connector.connection().dropDatabase();
|
68
|
+
|
69
|
+
const connection = root.connector.connection('connection'); // Get connection instance
|
70
|
+
console.log(connection);
|
71
|
+
|
72
|
+
await new root.test({
|
73
|
+
firstName: 'Vasya',
|
74
|
+
lastName: 'Pupkin',
|
75
|
+
age: 36,
|
76
|
+
}).save(); // insert data into test collection
|
77
|
+
|
78
|
+
// Get data from database
|
79
|
+
const data = await root.test.find({ firstName: 'Vasya' }, { _id: 0 });
|
80
|
+
console.log(data); // {
|
81
|
+
// firstName: 'Vasya',
|
82
|
+
// lastName: 'Pupkin',
|
83
|
+
// age: 36,
|
84
|
+
// }
|
85
|
+
})();
|
86
|
+
```
|
87
|
+
|
88
|
+
### Learn
|
89
|
+
|
90
|
+
- Documentation can be found here - [docs](https://biorate.github.io/core/modules/mongodb.html).
|
91
|
+
|
92
|
+
### Release History
|
93
|
+
|
94
|
+
See the [CHANGELOG](https://github.com/biorate/core/blob/master/packages/%40biorate/mongodb/CHANGELOG.md)
|
95
|
+
|
96
|
+
### License
|
97
|
+
|
98
|
+
[MIT](https://github.com/biorate/core/blob/master/packages/%40biorate/mongodb/LICENSE)
|
99
|
+
|
100
|
+
Copyright (c) 2021-present [Leonid Levkin (llevkin)](mailto:llevkin@yandex.ru)
|
package/dist/index.js
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./src"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MongoDBCantConnectError = void 0;
|
4
|
+
const errors_1 = require("@biorate/errors");
|
5
|
+
class MongoDBCantConnectError extends errors_1.BaseError {
|
6
|
+
constructor(e) {
|
7
|
+
super(`Can't connect to MongoDB: [%s]`, [e.message]);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.MongoDBCantConnectError = MongoDBCantConnectError;
|
11
|
+
//# sourceMappingURL=errors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAE5C,MAAa,uBAAwB,SAAQ,kBAAS;IACpD,YAAmB,CAAQ;QACzB,KAAK,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AAJD,0DAIC"}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
18
|
+
};
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
21
|
+
};
|
22
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.model = exports.MongoDBConnector = void 0;
|
27
|
+
const inversion_1 = require("@biorate/inversion");
|
28
|
+
const tools_1 = require("@biorate/tools");
|
29
|
+
const connector_1 = require("@biorate/connector");
|
30
|
+
const mongoose_1 = require("mongoose");
|
31
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
32
|
+
const errors_1 = require("./errors");
|
33
|
+
__exportStar(require("./errors"), exports);
|
34
|
+
__exportStar(require("./interfaces"), exports);
|
35
|
+
let MongoDBConnector = class MongoDBConnector extends connector_1.Connector {
|
36
|
+
constructor() {
|
37
|
+
super(...arguments);
|
38
|
+
this.namespace = 'MongoDB';
|
39
|
+
}
|
40
|
+
async connect(config) {
|
41
|
+
let connection;
|
42
|
+
try {
|
43
|
+
connection = (0, mongoose_1.createConnection)(config.host, config.options);
|
44
|
+
await tools_1.events.once(connection, 'open');
|
45
|
+
}
|
46
|
+
catch (e) {
|
47
|
+
throw new errors_1.MongoDBCantConnectError(e);
|
48
|
+
}
|
49
|
+
return connection;
|
50
|
+
}
|
51
|
+
async initialize() {
|
52
|
+
connections = this.connections;
|
53
|
+
await super.initialize();
|
54
|
+
}
|
55
|
+
};
|
56
|
+
__decorate([
|
57
|
+
(0, inversion_1.init)(),
|
58
|
+
__metadata("design:type", Function),
|
59
|
+
__metadata("design:paramtypes", []),
|
60
|
+
__metadata("design:returntype", Promise)
|
61
|
+
], MongoDBConnector.prototype, "initialize", null);
|
62
|
+
MongoDBConnector = __decorate([
|
63
|
+
(0, inversion_1.injectable)()
|
64
|
+
], MongoDBConnector);
|
65
|
+
exports.MongoDBConnector = MongoDBConnector;
|
66
|
+
let connections = null;
|
67
|
+
const model = (Model, connection, options = {}) => {
|
68
|
+
return (proto, key) => {
|
69
|
+
Object.defineProperty(proto, key, {
|
70
|
+
get() {
|
71
|
+
return (0, typegoose_1.getModelForClass)(Model, {
|
72
|
+
existingConnection: connection
|
73
|
+
? connections.get(connection)
|
74
|
+
: [...connections][0][1],
|
75
|
+
options,
|
76
|
+
});
|
77
|
+
},
|
78
|
+
configurable: false,
|
79
|
+
});
|
80
|
+
};
|
81
|
+
};
|
82
|
+
exports.model = model;
|
83
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAsD;AACtD,0CAAwC;AACxC,kDAA+C;AAC/C,uCAA4C;AAC5C,oDAAwD;AACxD,qCAAmD;AAGnD,2CAAyB;AACzB,+CAA6B;AA2F7B,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,qBAA6C;IAAnF;;QAIqB,cAAS,GAAG,SAAS,CAAC;IAqB3C,CAAC;IAjBW,KAAK,CAAC,OAAO,CAAC,MAAsB;QAC5C,IAAI,UAAU,CAAC;QACf,IAAI;YACF,UAAU,GAAG,IAAA,2BAAgB,EAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3D,MAAM,cAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;SACvC;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,gCAAuB,CAAC,CAAC,CAAC,CAAC;SACtC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAIiB,KAAK,CAAC,UAAU;QAChC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAC/B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAJS;IAAP,IAAA,gBAAI,GAAE;;;;kDAGN;AAxBU,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;GACA,gBAAgB,CAyB5B;AAzBY,4CAAgB;AA6B7B,IAAI,WAAW,GAAoC,IAAI,CAAC;AAIjD,MAAM,KAAK,GAAG,CACnB,KAA8B,EAC9B,UAAmB,EACnB,UAAmC,EAAE,EACrC,EAAE;IACF,OAAO,CAAC,KAAW,EAAE,GAAY,EAAE,EAAE;QACnC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE;YAChC,GAAG;gBACD,OAAO,IAAA,4BAAgB,EAAC,KAAK,EAAE;oBAC7B,kBAAkB,EAAE,UAAU;wBAC5B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;wBAC7B,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1B,OAAO;iBACR,CAAC,CAAC;YACL,CAAC;YACD,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,KAAK,SAkBhB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.full.d.ts","../../inversion/node_modules/reflect-metadata/index.d.ts","../../inversion/node_modules/inversify/lib/constants/metadata_keys.d.ts","../../inversion/node_modules/inversify/lib/interfaces/interfaces.d.ts","../../inversion/node_modules/inversify/lib/container/container.d.ts","../../inversion/node_modules/inversify/lib/constants/literal_types.d.ts","../../inversion/node_modules/inversify/lib/container/container_module.d.ts","../../inversion/node_modules/inversify/lib/annotation/injectable.d.ts","../../inversion/node_modules/inversify/lib/annotation/tagged.d.ts","../../inversion/node_modules/inversify/lib/annotation/named.d.ts","../../inversion/node_modules/inversify/lib/annotation/inject.d.ts","../../inversion/node_modules/inversify/lib/annotation/optional.d.ts","../../inversion/node_modules/inversify/lib/annotation/unmanaged.d.ts","../../inversion/node_modules/inversify/lib/annotation/multi_inject.d.ts","../../inversion/node_modules/inversify/lib/annotation/target_name.d.ts","../../inversion/node_modules/inversify/lib/annotation/post_construct.d.ts","../../inversion/node_modules/inversify/lib/planning/metadata_reader.d.ts","../../inversion/node_modules/inversify/lib/utils/id.d.ts","../../inversion/node_modules/inversify/lib/annotation/decorator_utils.d.ts","../../inversion/node_modules/inversify/lib/syntax/constraint_helpers.d.ts","../../inversion/node_modules/inversify/lib/utils/serialization.d.ts","../../inversion/node_modules/inversify/lib/utils/binding_utils.d.ts","../../inversion/node_modules/inversify/lib/inversify.d.ts","../../inversion/node_modules/inversify-inject-decorators/dts/index.d.ts","../../inversion/interfaces.ts","../../symbolic/src/index.ts","../../symbolic/index.ts","../../inversion/src/labels.ts","../../inversion/src/inversify.ts","../../../../node_modules/reflect-metadata/index.d.ts","../../../../node_modules/@types/lodash/common/common.d.ts","../../../../node_modules/@types/lodash/common/array.d.ts","../../../../node_modules/@types/lodash/common/collection.d.ts","../../../../node_modules/@types/lodash/common/date.d.ts","../../../../node_modules/@types/lodash/common/function.d.ts","../../../../node_modules/@types/lodash/common/lang.d.ts","../../../../node_modules/@types/lodash/common/math.d.ts","../../../../node_modules/@types/lodash/common/number.d.ts","../../../../node_modules/@types/lodash/common/object.d.ts","../../../../node_modules/@types/lodash/common/seq.d.ts","../../../../node_modules/@types/lodash/common/string.d.ts","../../../../node_modules/@types/lodash/common/util.d.ts","../../../../node_modules/@types/lodash/index.d.ts","../../errors/index.ts","../../tools/src/errors.ts","../../tools/src/env.ts","../../tools/src/path.ts","../../tools/src/object.ts","../../tools/interfaces.ts","../../tools/src/define.ts","../../tools/src/timer.ts","../../tools/src/events.ts","../../tools/src/buffer.ts","../../tools/src/index.ts","../../tools/index.ts","../../lifecycled/src/index.ts","../../lifecycled/index.ts","../../inversion/src/index.ts","../../inversion/index.ts","../../config/src/errors.ts","../../config/src/interfaces.ts","../../config/src/index.ts","../../config/index.ts","../../connector/src/interfaces.ts","../../connector/src/errors.ts","../../connector/src/index.ts","../../connector/index.ts","../node_modules/@types/node/assert.d.ts","../node_modules/@types/node/assert/strict.d.ts","../node_modules/@types/node/globals.d.ts","../node_modules/@types/node/async_hooks.d.ts","../node_modules/@types/node/buffer.d.ts","../node_modules/@types/node/child_process.d.ts","../node_modules/@types/node/cluster.d.ts","../node_modules/@types/node/console.d.ts","../node_modules/@types/node/constants.d.ts","../node_modules/@types/node/crypto.d.ts","../node_modules/@types/node/dgram.d.ts","../node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/@types/node/dns.d.ts","../node_modules/@types/node/dns/promises.d.ts","../node_modules/@types/node/domain.d.ts","../node_modules/@types/node/events.d.ts","../node_modules/@types/node/fs.d.ts","../node_modules/@types/node/fs/promises.d.ts","../node_modules/@types/node/http.d.ts","../node_modules/@types/node/http2.d.ts","../node_modules/@types/node/https.d.ts","../node_modules/@types/node/inspector.d.ts","../node_modules/@types/node/module.d.ts","../node_modules/@types/node/net.d.ts","../node_modules/@types/node/os.d.ts","../node_modules/@types/node/path.d.ts","../node_modules/@types/node/perf_hooks.d.ts","../node_modules/@types/node/process.d.ts","../node_modules/@types/node/punycode.d.ts","../node_modules/@types/node/querystring.d.ts","../node_modules/@types/node/readline.d.ts","../node_modules/@types/node/repl.d.ts","../node_modules/@types/node/stream.d.ts","../node_modules/@types/node/stream/promises.d.ts","../node_modules/@types/node/stream/consumers.d.ts","../node_modules/@types/node/stream/web.d.ts","../node_modules/@types/node/string_decoder.d.ts","../node_modules/@types/node/timers.d.ts","../node_modules/@types/node/timers/promises.d.ts","../node_modules/@types/node/tls.d.ts","../node_modules/@types/node/trace_events.d.ts","../node_modules/@types/node/tty.d.ts","../node_modules/@types/node/url.d.ts","../node_modules/@types/node/util.d.ts","../node_modules/@types/node/v8.d.ts","../node_modules/@types/node/vm.d.ts","../node_modules/@types/node/wasi.d.ts","../node_modules/@types/node/worker_threads.d.ts","../node_modules/@types/node/zlib.d.ts","../node_modules/@types/node/globals.global.d.ts","../node_modules/@types/node/index.d.ts","../node_modules/buffer/index.d.ts","../node_modules/bson/bson.d.ts","../node_modules/denque/index.d.ts","../node_modules/mongodb/mongodb.d.ts","../node_modules/mongoose/types/aggregate.d.ts","../node_modules/mongoose/types/connection.d.ts","../node_modules/mongoose/types/cursor.d.ts","../node_modules/mongoose/types/document.d.ts","../node_modules/mongoose/types/error.d.ts","../node_modules/mongoose/types/mongooseoptions.d.ts","../node_modules/mongoose/types/pipelinestage.d.ts","../node_modules/mongoose/types/schemaoptions.d.ts","../node_modules/mongoose/types/index.d.ts","../node_modules/reflect-metadata/index.d.ts","../node_modules/@typegoose/typegoose/lib/internal/constants.d.ts","../node_modules/@typegoose/typegoose/lib/types.d.ts","../node_modules/@typegoose/typegoose/lib/globalOptions.d.ts","../node_modules/loglevel/index.d.ts","../node_modules/@typegoose/typegoose/lib/logSettings.d.ts","../node_modules/@typegoose/typegoose/lib/prop.d.ts","../node_modules/@typegoose/typegoose/lib/hooks.d.ts","../node_modules/@typegoose/typegoose/lib/plugin.d.ts","../node_modules/@typegoose/typegoose/lib/index.d.ts","../node_modules/@typegoose/typegoose/lib/modelOptions.d.ts","../node_modules/@typegoose/typegoose/lib/queryMethod.d.ts","../node_modules/@typegoose/typegoose/lib/typeguards.d.ts","../node_modules/@typegoose/typegoose/lib/defaultClasses.d.ts","../node_modules/@typegoose/typegoose/lib/internal/errors.d.ts","../node_modules/@typegoose/typegoose/lib/internal/utils.d.ts","../node_modules/@typegoose/typegoose/lib/typegoose.d.ts","../src/errors.ts","../src/interfaces.ts","../src/index.ts","../index.ts","../node_modules/@types/webidl-conversions/index.d.ts","../node_modules/@types/whatwg-url/index.d.ts","../../../../node_modules/@types/babel-types/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../../../node_modules/@types/babel__traverse/index.d.ts","../../../../node_modules/@types/babylon/index.d.ts","../../../../node_modules/@types/chai/index.d.ts","../../../../node_modules/@types/eslint/helpers.d.ts","../../../../node_modules/@types/json-schema/index.d.ts","../../../../node_modules/@types/estree/index.d.ts","../../../../node_modules/@types/eslint/index.d.ts","../../../../node_modules/@types/eslint-scope/index.d.ts","../../../../node_modules/@types/minimatch/index.d.ts","../../../../node_modules/@types/glob/index.d.ts","../../../../node_modules/@types/graceful-fs/index.d.ts","../../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../../node_modules/@types/istanbul-reports/index.d.ts","../../../../node_modules/@types/minimist/index.d.ts","../../../../node_modules/@types/mocha/index.d.ts","../../../../node_modules/@types/normalize-package-data/index.d.ts","../../../../node_modules/@types/parse-json/index.d.ts","../../../../node_modules/@types/prettier/index.d.ts","../../../../node_modules/@types/stack-utils/index.d.ts","../../../../node_modules/@types/yargs-parser/index.d.ts","../../../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"dbb73d4d99be496175cb432c74c2615f78c76f4272f1d83cba11ee0ed6dbddf0","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"5075b36ab861c8c0c45377cb8c96270d7c65f0eeaf105d53fac6850da61f1027","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"d2f31f19e1ba6ed59be9259d660a239d9a3fcbbc8e038c6b2009bde34b175fed",{"version":"8d6d51a5118d000ed3bfe6e1dd1335bebfff3fef23cd2af2f84a24d30f90cc90","affectsGlobalScope":true},"e72fe8c20f176ecfbb89b47e0956ad5af5c79d00a813db6adf32d7a323827bde","234ded1b44862f6c114c060f11e4cfd2fbace2a0988b886c4d2273da64721ca3","15c78ee71828fbcff296ef228440f459fefa3d7afaa4ed5dcf473ef67729ce28","223c30250c2d0774405136fe412f0c654acbd1f5ebc80d711d0a4413ced11520","d21addb8e9f07e85fe34b65dd38d156b2d29491585eb3a2d3754c85ff024dc78","45f14437278936644e7aa944a9d7b3213cc74173a9d0a6e78994de43caccb6d7","43769897ae7ca754acaffec5dfb909d10510fb2be0d0afa5cb4eec91b4c9805a","188fd1724740c445a782b9e953879097edef90434ff76fdc420acfbd58b1bcf6","3bdef47778e6ef0896e60bc227562685efedb3aee3fb132b5a968e892b0bff0b","f81c99df7c78e3ad3b6eacbaa5d5a2d36bcab1ea029b1998ede9151861502a9d","9fd895b4e65cc84529969de404b2221a95a955a57544febdc76189689696b040","c656a8d0be8f60c6818d5c60ec56fbe61de252cffb98b760dc0ba5518e85b86a","1f0a68bc4e44a72d2e3ce81967f6001df5d29428549b310054df0fa1bf588203","d9df733eeb4fc5ca64d6dfcaa3efc429a9fa7d183ce796df0e5049c1acd1eaa7","617d9598bd1dbc6b4e19ebabc5564b3fb9a95589f52eefb4c04396f292f7d1ef","c624c0d0d777a670e2b2d8003ec91519e93048963a3236aeab1ec55a8529c382","5436e41fb86218a81a15f6517dc47736924b4a31d1b04a2ca4405556a7bdd303","388e00b3c8426cf875a3b764a1d2f4d1669f05e587ad511fb7d61684e3fc5352","21a9fdf5ec213b187243a4fee33cce7055a0e25dd2ab6fd5eb53d9063bda1297","8ea54168630a0cbd9127985d4190ad962ad55123d78e855d7e505a7bf042bc2d","f15dd6db666e773db7ae7eba550607eeede04d16819dc7a5abf546f15a4b989a","961700b34af98c4b8049a6a8580195d3c5d07b7d82d3944587b8cabc70a00129","ae11ffbbb53d65a0b217333581526d5d280398df5c212d511f22ab2f5c6991f1","92e9e32485f6fea2ca0e00d30d7f66ce47402bfe0c6db4273e380daf6c0e63c8","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","665e3f8e4b15f4fa90b182edd6de96ce49676325024b12b29950bbc91827063b","bcf97adb421d37536e9d201274f72bb9deaac5e465cede7650fffd69a55875c9",{"version":"8d6d51a5118d000ed3bfe6e1dd1335bebfff3fef23cd2af2f84a24d30f90cc90","affectsGlobalScope":true},"675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","fe4a2042d087990ebfc7dc0142d5aaf5a152e4baea86b45f283f103ec1e871ea","d70c026dd2eeaa974f430ea229230a1897fdb897dc74659deebe2afd4feeb08f","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","febf0b2de54781102b00f61653b21377390a048fbf5262718c91860d11ff34a6","ca59fe42b81228a317812e95a2e72ccc8c7f1911b5f0c2a032adf41a0161ec5d","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","ae9930989ed57478eb03b9b80ad3efa7a3eacdfeff0f78ecf7894c4963a64f93","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","df996e25faa505f85aeb294d15ebe61b399cf1d1e49959cdfaf2cc0815c203f9",{"version":"f2eff8704452659641164876c1ef0df4174659ce7311b0665798ea3f556fa9ad","affectsGlobalScope":true},"d47a7e17d32b099d75e6288b67324de01a0587e5b8f2ed5c6289a8a7567e1be0","96a3cd0508294f8476c0b9634684e410a122e4c41f4f2b3a27a417d23e8296e2","4eb9bbb381dd5cfbd9f21408444c38ad579cba4de3e1c857019091dbf7c9a031","e76aaff856531ff082869f9a820bb1a0b2d0713365396b3997c5fe9b457bb73c","bd642322f25c6eaccb1049adda0086b486da4084a3c112fa9499c66fc2873d3f","8498554c116ec8289c7fe33ed67e36ba801a7e8acdd04ce32c9e864448738bc0","135facafb712b318733713fafdb7e2768e459f96e4971908c75d52956ac645c4","dfd544a9e06dbdb0c7c0a52d5ae5f7ca980fe04c65cd0ee9de4860ac2d38374b","da53b3f81accffc2e119cf2b1e4a5da3bad86042fe9ce4169166750644de5c0c","513ec76301e5d66ba0f5194a9be459c0f595beb1c5fb6e31a5d1c3e920a8b4bd","ebcf1781ee9aa2534792360c2dee38697372f31e24c8c33e35bfa414207ce72f","e0538e0a052324c35c22e22f61f1fe733eed97e68cb6e00aeac901f5e6e4e95c","54c2d7502e8ca2cf2b568e395874d810a76c649ffa9e1939e85fb5b775e89404","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","c4b26d58e06671d2c62928ee929e0f862bd6b4404199bd3a1fd87cea6cf8f3b5","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","0e2becb7a24e44ae138fe34d93c7a6583d738cd3347720b725e986e9c59a6d19","bdfe71979c31b7fd6391fe3882cab028d3ee39fe751218580af0e056fb6734aa","59cbe8a6f12f3526c804d9560d40e3d089bb7ad021ae950a480c357c1f79cab7","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","ef44188502c439a13052640bc755a2f85f5f8a96d454a0aac17aba156e795c18","364d890be1c074ff8aa1d3ef5a8e711f4f2b17ea69121719d937a0f15d376bf9","30dac3604771918c3a3fa91595fb400b5f3781cc8818caea1ca66cde73c4d9b5","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"c2ab70bbc7a24c42a790890739dd8a0ba9d2e15038b40dff8163a97a5d148c00","affectsGlobalScope":true},"422dbb183fdced59425ca072c8bd09efaa77ce4e2ab928ec0d8a1ce062d2a45a",{"version":"fcdcb42da18dd98dc286b1876dd425791772036012ae61263c011a76b13a190f","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","918a76828d88a73924bb26fef58040a6eb8a9adb7e407ea7264175520dda9450","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","cc0b61316c4f37393f1f9595e93b673f4184e9d07f4c127165a490ec4a928668","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"bfea28e6162ed21a0aeed181b623dcf250aa79abf49e24a6b7e012655af36d81","affectsGlobalScope":true},"b8aca9d0c81abb02bec9b7621983ae65bde71da6727580070602bd2500a9ce2a","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","10d4796a130577d57003a77b95d8723530bbec84718e364aa2129fa8ffba0378","ad41bb744149e92adb06eb953da195115620a3f2ad48e7d3ae04d10762dae197","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"287b21dc1d1b9701c92e15e7dd673dfe6044b15812956377adffb6f08825b1bc","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"4cd4cff679c9b3d9239fd7bf70293ca4594583767526916af8e5d5a47d0219c7","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","00fa7ce8bc8acc560dc341bbfdf37840a8c59e6a67c9bfa3fa5f36254df35db2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"3345c276cab0e76dda86c0fb79104ff915a4580ba0f3e440870e183b1baec476","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","103d70bfbeb3cd3a3f26d1705bf986322d8738c2c143f38ebb743b1e228d7444","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7",{"version":"3a2da34079a2567161c1359316a32e712404b56566c45332ac9dcee015ecce9f","affectsGlobalScope":true},"28a2e7383fd898c386ffdcacedf0ec0845e5d1a86b5a43f25b86bc315f556b79","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"9cafe917bf667f1027b2bb62e2de454ecd2119c80873ad76fc41d941089753b8","8e9c23ba78aabc2e0a27033f18737a6df754067731e69dc5f52823957d60a4b6","ea5aa4d1e53916a4aaf9d7e03203dd74544bb13c0d35b0bd7a64b31a5c086d0f","ed849d616865076f44a41c87f27698f7cdf230290c44bafc71d7c2bc6919b202","760bc25d2ecc01b6350b1ed879938fe23828d551d143c7c1d44881aa9c0ae215","548d87a63879fc6f7284ccc2a8ba3e826efa7e6fd71e7be90838644f72f077fa","ed1ac892cfc22b7fb5dd19a81ca483d571c71e185ed899f1635937abf9ef4485","441dfc5b0f639cd2e6ca95aec0ffdaffe629aa8d5ad275ace258184d0f4d9835","7d035aa7c39c3cb5cac36c6beeb3fe122fe1bef316dac5ba89f87f5f14234114","f96298e5796b2ae0602d6215315f68e6d95dc6f39811c770495bc17ac36d76a9","72b725db76148eb049bea6a38386ea4655d09412125110c3bd9f575b23f74923","379cbd2c7130c5b7bd276fa38c971b82e60b6f11dc90fe8a094d433a96c4d431","38fb0dc073c33cad8e90a4beb0129847ec037585bb4b3a5f6dc7dfd32695461d","d6bb56ff7a2b8d064ee9a953058fb0c08651faaeaf1af149674c7bc4ad88dd9c",{"version":"8d6d51a5118d000ed3bfe6e1dd1335bebfff3fef23cd2af2f84a24d30f90cc90","affectsGlobalScope":true},"76f17cefc3aafe622f54a3682cd4af724b13acf51b025a68444712953fd4ebf3","694c8adbf2b775deecc695fa6b0405c44d1512ecb30b60584b53ca3ee107bf75","52c84ce269429c916f743c8d1c564d2860f26a586a3b5f2014cfec509aa823ca","34c7fb7e892ea21376cebad4c3c29bdb10324606d58af04bfc2c7b8c8d41af4d","a8073882d24e2c886bd020a24d713c0d5339a5ef02880fc6ac37a8fbd8249ded","25f7970b0bd491602b0a5be776ebe1cbffbee9147298220f71007d644a5f23ac","3fc28a7def4a37cf1670461e04014ec58765ffc14885ca3070b697d7e724afd7","67a323d2326c788a964e3eddb499a3127e9f40a117fd31b83efca14c56fdb54b","137a225a43b95c4215a5214828d672b4e66aff5c70e7e7fa36a35fac45739c75","3ffd867f0c22237ef2bd6d0d1a179381b5b9356f8b917817b7b1d6f731e5afb8","4511b4bb7c49f91194e667ee19fee54402842fed758ea782d361fea0bf0b1d9a","c93314fe92e233b7900df3cc4c68e5ac5563db2c4465000eceb49d5d14157e5b","0cd5ee6f69d612cefd1920560dbf40e33dd2dfdfa0784b278052cfbed8f31052","45377898885cd0797826ff67df85ee53d462b9842d62d1f6a4ff31996e905f4d","22cc081d6dbdfa0932a031a6e522da11f9ad022e879b6b7b64b3a2c50facd610","a2d5f0ebd6ca4bd54a3e43d8e9107d4e7392922e41a3d4d92286334004c60322","5b8bc25fb91ec9d01d7115cc220b5d3702284b466348a65bc8dd263eb8f393db","9fd4ffe724c729d2fc264a2920cab1bd176d2ce3306d01afa7a71227ff4f1898","d961d492ff0b48c9a0c9cd4f700abf1196b24fd4edbd0402119d388f97ca4841","80a3bbe0e4fdfaac2c0a8b92a3ed66d3ded5e8f454c5790c8d593872fc1197f1","95d085761c8e8d469a9066a9cc7bd4b5bc671098d2f8442ae657fb35b3215cf1","67483628398336d0f9368578a9514bd8cc823a4f3b3ab784f3942077e5047335","75925c52e539a150d822acf3d43f41075d6c371215be27e0c81215a79a802fb4","2ff9995137f3e5d68971388ec58af0c79721626323884513f9f5e2e996ac1fdd","159bda82b67a7aa30cf7dcf0110cad83bcc6620396830efd470890f0caa6c9c0","b76275b4a94b85da9e4b6b1f8c2b619b996560f9e6030a454260240210a39dd8",{"version":"3a15910b7f45dfc393f010ee8f913580b08d65752800fc48147ea13445acd5f7","affectsGlobalScope":true},{"version":"64d4b35c5456adf258d2cf56c341e203a073253f229ef3208fc0d5020253b241","affectsGlobalScope":true},"f3e604694b624fa3f83f6684185452992088f5efb2cf136b62474aa106d6f1b6","a1c79f857f5c7754e14c93949dad8cfefcd7df2ecc0dc9dd79a30fd493e28449","8566fa84085caa46340393b1704ecd368491918fb45bd688d6e89736aec73a2f","dc33ce27fbeaf0ea3da556c80a6cc8af9d13eb443088c8f25cdc39fca8e756f6","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba","8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","209e814e8e71aec74f69686a9506dd7610b97ab59dcee9446266446f72a76d05",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true},"6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a","2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","429b6df7d7b94389bd42cfdf39bccea903acd3628498cec6172302801fbeac89","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","70e9a18da08294f75bf23e46c7d69e67634c0765d355887b9b41f0d959e1426e","6ba73232c9d3267ca36ddb83e335d474d2c0e167481e3dec416c782894e11438"],"options":{"allowSyntheticDefaultImports":true,"declaration":false,"emitDecoratorMetadata":true,"experimentalDecorators":true,"jsx":2,"module":1,"outDir":"./","removeComments":true,"sourceMap":true,"target":4},"fileIdsList":[[153],[153,198],[153,197],[153,204,205],[153,202,203,204],[125,126,153,160,207],[126,153,160],[153,210],[153,211],[73,75,76,77,78,79,80,81,82,83,84,85,153],[73,74,76,77,78,79,80,81,82,83,84,85,153],[74,75,76,77,78,79,80,81,82,83,84,85,153],[73,74,75,77,78,79,80,81,82,83,84,85,153],[73,74,75,76,78,79,80,81,82,83,84,85,153],[73,74,75,76,77,79,80,81,82,83,84,85,153],[73,74,75,76,77,78,80,81,82,83,84,85,153],[73,74,75,76,77,78,79,81,82,83,84,85,153],[73,74,75,76,77,78,79,80,82,83,84,85,153],[73,74,75,76,77,78,79,80,81,83,84,85,153],[73,74,75,76,77,78,79,80,81,82,84,85,153],[73,74,75,76,77,78,79,80,81,82,83,85,153],[73,74,75,76,77,78,79,80,81,82,83,84,153],[153,219],[104,153],[85,86,153],[85,101,102,103,153],[85,153],[108,153],[86,153],[101,105,106,107,153],[100,153],[65,153],[46,153],[45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,153],[44,70,71,99,153],[65,66,67,70,153],[69,153],[98,153],[44,85,97,153],[153,193],[153,165,166,167,168,169,170,171,172,173,176],[153,175,176],[153,165,166,167,168,169,170,171,172,173,176,190],[153,176],[153,165,166,167,168,169,170,171,172,173,175,176],[153,178],[44,153,165,166,167,168,169,170,171,172,173,175,176,177,179,180,181,182,183,184,185,186,187,188,189],[153,160,165,166,167,168,169,170,171,172,173,176],[153,165,166,167,168,169,170,171,172,173,175],[110,153],[113,153],[114,119,153],[115,125,126,133,142,152,153],[115,116,125,133,153],[117,153],[118,119,126,134,153],[119,142,149,153],[120,122,125,133,153],[121,153],[122,123,153],[124,125,153],[125,153],[125,126,127,142,152,153],[125,126,127,142,153],[128,133,142,152,153],[125,126,128,129,133,142,149,152,153],[128,130,142,149,152,153],[110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159],[125,131,153],[132,152,153],[122,125,133,142,153],[134,153],[135,153],[113,136,153],[137,151,153,157],[138,153],[139,153],[125,140,153],[140,141,153,155],[125,142,143,144,153],[142,144,153],[142,143,153],[145,153],[146,153],[125,147,148,153],[147,148,153],[119,133,142,149,153],[150,153],[133,151,153],[114,128,139,152,153],[119,153],[142,153,154],[153,155],[153,156],[114,119,125,127,136,142,152,153,155,157],[142,153,158],[153,160],[114,153],[122,125,133,142,149,153,160,162,163],[153,164,166,167,168,169,170,171,172,173],[125,153,164,165,167,168,169,170,171,172,173],[142,153,165,166,168,169,170,171,172,173],[153,164,165,166,167,169,170,171,172,173],[153,164,165,166,167,168,170,171,172,173],[125,153,164,165,166,167,168,169,170,171,172,173],[142,153,165,166,167,168,169,171,172,173],[153,164,165,166,167,168,169,170,171,173],[97,101,109,153,165,166,167,168,169,170,171,172,173,190,191,192],[109,153,165,166,167,168,169,170,171,172,173],[68,153],[91,96,153],[87,153],[91,153],[87,88,89,90,92,93,94,95,153]],"referencedMap":[[198,1],[197,1],[199,2],[200,3],[201,1],[206,4],[202,1],[205,5],[204,1],[208,6],[209,7],[210,1],[211,8],[212,9],[203,1],[74,10],[75,11],[73,12],[76,13],[77,14],[78,15],[79,16],[80,17],[81,18],[82,19],[83,20],[84,21],[85,22],[207,1],[213,1],[214,1],[215,1],[216,1],[217,1],[218,1],[219,1],[220,23],[72,1],[8,1],[9,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[43,1],[25,1],[22,1],[23,1],[24,1],[26,1],[27,1],[28,1],[5,1],[29,1],[30,1],[31,1],[32,1],[6,1],[33,1],[34,1],[35,1],[36,1],[7,1],[41,1],[37,1],[38,1],[39,1],[40,1],[1,1],[42,1],[11,1],[10,1],[105,24],[102,25],[104,26],[103,27],[109,28],[107,29],[108,30],[106,1],[86,1],[101,31],[67,1],[66,32],[61,33],[53,33],[50,1],[56,33],[52,1],[54,1],[58,1],[51,1],[57,1],[55,1],[48,33],[45,1],[47,33],[49,33],[46,1],[65,34],[59,33],[62,33],[64,32],[60,1],[63,33],[44,1],[100,35],[71,36],[70,37],[99,38],[98,39],[194,40],[187,41],[177,42],[181,43],[183,44],[175,1],[188,1],[189,45],[179,46],[184,44],[182,44],[180,42],[185,41],[190,47],[186,48],[176,49],[110,50],[111,50],[113,51],[114,52],[115,53],[116,54],[117,55],[118,56],[119,57],[120,58],[121,59],[122,60],[123,60],[124,61],[125,62],[126,63],[127,64],[112,1],[159,1],[128,65],[129,66],[130,67],[160,68],[131,69],[132,70],[133,71],[134,72],[135,73],[136,74],[137,75],[138,76],[139,77],[140,78],[141,79],[142,80],[144,81],[143,82],[145,83],[146,84],[147,85],[148,86],[149,87],[150,88],[151,89],[152,90],[153,91],[154,92],[155,93],[156,94],[157,95],[158,96],[195,1],[196,97],[162,98],[161,1],[163,1],[178,1],[164,99],[165,100],[166,101],[167,102],[168,103],[169,104],[173,105],[170,106],[171,1],[172,107],[174,1],[191,29],[193,108],[192,109],[69,110],[68,1],[97,111],[91,1],[95,112],[92,113],[88,1],[87,29],[94,1],[96,114],[90,1],[89,73],[93,1]],"exportedModulesMap":[[198,1],[197,1],[199,2],[200,3],[201,1],[206,4],[202,1],[205,5],[204,1],[208,6],[209,7],[210,1],[211,8],[212,9],[203,1],[74,10],[75,11],[73,12],[76,13],[77,14],[78,15],[79,16],[80,17],[81,18],[82,19],[83,20],[84,21],[85,22],[207,1],[213,1],[214,1],[215,1],[216,1],[217,1],[218,1],[219,1],[220,23],[72,1],[8,1],[9,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[43,1],[25,1],[22,1],[23,1],[24,1],[26,1],[27,1],[28,1],[5,1],[29,1],[30,1],[31,1],[32,1],[6,1],[33,1],[34,1],[35,1],[36,1],[7,1],[41,1],[37,1],[38,1],[39,1],[40,1],[1,1],[42,1],[11,1],[10,1],[105,24],[102,25],[104,26],[103,27],[109,28],[107,29],[108,30],[106,1],[86,1],[101,31],[67,1],[66,32],[61,33],[53,33],[50,1],[56,33],[52,1],[54,1],[58,1],[51,1],[57,1],[55,1],[48,33],[45,1],[47,33],[49,33],[46,1],[65,34],[59,33],[62,33],[64,32],[60,1],[63,33],[44,1],[100,35],[71,36],[70,37],[99,38],[98,39],[194,40],[187,41],[177,42],[181,43],[183,44],[175,1],[188,1],[189,45],[179,46],[184,44],[182,44],[180,42],[185,41],[190,47],[186,48],[176,49],[110,50],[111,50],[113,51],[114,52],[115,53],[116,54],[117,55],[118,56],[119,57],[120,58],[121,59],[122,60],[123,60],[124,61],[125,62],[126,63],[127,64],[112,1],[159,1],[128,65],[129,66],[130,67],[160,68],[131,69],[132,70],[133,71],[134,72],[135,73],[136,74],[137,75],[138,76],[139,77],[140,78],[141,79],[142,80],[144,81],[143,82],[145,83],[146,84],[147,85],[148,86],[149,87],[150,88],[151,89],[152,90],[153,91],[154,92],[155,93],[156,94],[157,95],[158,96],[195,1],[196,97],[162,98],[161,1],[163,1],[178,1],[164,99],[165,100],[166,101],[167,102],[168,103],[169,104],[173,105],[170,106],[171,1],[172,107],[174,1],[191,29],[193,108],[192,109],[69,110],[68,1],[97,111],[91,1],[95,112],[92,113],[88,1],[87,29],[94,1],[96,114],[90,1],[89,73],[93,1]],"semanticDiagnosticsPerFile":[198,197,199,200,201,206,202,205,204,208,209,210,211,212,203,74,75,73,76,77,78,79,80,81,82,83,84,85,207,213,214,215,216,217,218,219,220,72,8,9,13,12,2,14,15,16,17,18,19,20,21,3,4,43,25,22,23,24,26,27,28,5,29,30,31,32,6,33,34,35,36,7,41,37,38,39,40,1,42,11,10,105,102,104,103,109,107,108,106,86,101,67,66,61,53,50,56,52,54,58,51,57,55,48,45,47,49,46,65,59,62,64,60,63,44,100,71,70,99,98,194,187,177,181,183,175,188,189,179,184,182,180,185,190,186,176,110,111,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,112,159,128,129,130,160,131,132,133,134,135,136,137,138,139,140,141,142,144,143,145,146,147,148,149,150,151,152,153,154,155,156,157,158,195,196,162,161,163,178,164,165,166,167,168,169,173,170,171,172,174,191,193,192,69,68,97,91,95,92,88,87,94,96,90,89,93]},"version":"4.6.3"}
|
package/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './src';
|
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "@biorate/mongodb",
|
3
|
+
"version": "0.26.0",
|
4
|
+
"description": "Mongodb ORM connector based on mongoose and typegoose",
|
5
|
+
"main": "dist",
|
6
|
+
"scripts": {
|
7
|
+
"build": "npx tsc -p ./tsconfig.build.json --outDir ./dist",
|
8
|
+
"test": "npx nyc --reporter=lcov --reporter=text-summary -- npx mocha --exit -r ts-node/register tests/**/*.spec.ts",
|
9
|
+
"prepublishOnly": "npm run build"
|
10
|
+
},
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "git+https://github.com/biorate/core.git",
|
14
|
+
"directory": "packages/@biorate/mongodb"
|
15
|
+
},
|
16
|
+
"publishConfig": {
|
17
|
+
"access": "public"
|
18
|
+
},
|
19
|
+
"homepage": "https://biorate.github.io/core",
|
20
|
+
"keywords": [
|
21
|
+
"mongodb",
|
22
|
+
"connector"
|
23
|
+
],
|
24
|
+
"author": "llevkin",
|
25
|
+
"license": "MIT",
|
26
|
+
"dependencies": {
|
27
|
+
"@biorate/config": "0.26.0",
|
28
|
+
"@biorate/connector": "0.26.0",
|
29
|
+
"@biorate/errors": "0.26.0",
|
30
|
+
"@biorate/inversion": "0.26.0",
|
31
|
+
"@biorate/tools": "0.26.0",
|
32
|
+
"@typegoose/typegoose": "^9.8.1",
|
33
|
+
"mongodb": "^4.5.0",
|
34
|
+
"mongoose": "^6.3.1"
|
35
|
+
},
|
36
|
+
"gitHead": "5baf628ba6d10af00260d3774074f1f1468554e0"
|
37
|
+
}
|
package/src/errors.ts
ADDED
package/src/index.ts
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
import { init, injectable } from '@biorate/inversion';
|
2
|
+
import { events } from '@biorate/tools';
|
3
|
+
import { Connector } from '@biorate/connector';
|
4
|
+
import { createConnection } from 'mongoose';
|
5
|
+
import { getModelForClass } from '@typegoose/typegoose';
|
6
|
+
import { MongoDBCantConnectError } from './errors';
|
7
|
+
import { IMongoDBConfig, IMongoDBConnection } from './interfaces';
|
8
|
+
|
9
|
+
export * from './errors';
|
10
|
+
export * from './interfaces';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @description Mongodb ORM connector based on mongoose and typegoose
|
14
|
+
*
|
15
|
+
* ### Features:
|
16
|
+
* - connector manager for mongodb
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* ```
|
20
|
+
* import { inject, container, Types, Core } from '@biorate/inversion';
|
21
|
+
* import { IConfig, Config } from '@biorate/config';
|
22
|
+
* import {
|
23
|
+
* Severity,
|
24
|
+
* modelOptions,
|
25
|
+
* Prop,
|
26
|
+
* MongoDBConnector,
|
27
|
+
* IMongoDBConnector,
|
28
|
+
* model,
|
29
|
+
* ReturnModelType,
|
30
|
+
* } from '@biorate/mongodb';
|
31
|
+
*
|
32
|
+
* // Define models
|
33
|
+
* @modelOptions({
|
34
|
+
* options: {
|
35
|
+
* allowMixed: Severity.ALLOW,
|
36
|
+
* },
|
37
|
+
* schemaOptions: { collection: 'test', versionKey: false },
|
38
|
+
* })
|
39
|
+
* export class TestModel {
|
40
|
+
* @Prop()
|
41
|
+
* firstName: string;
|
42
|
+
*
|
43
|
+
* @Prop()
|
44
|
+
* lastName: string;
|
45
|
+
*
|
46
|
+
* @Prop()
|
47
|
+
* age: number;
|
48
|
+
* }
|
49
|
+
*
|
50
|
+
* // Define root
|
51
|
+
* export class Root extends Core() {
|
52
|
+
* @inject(MongoDBConnector) public connector: IMongoDBConnector;
|
53
|
+
* @model(TestModel) public test: ReturnModelType<typeof TestModel>;
|
54
|
+
* }
|
55
|
+
*
|
56
|
+
* // Bind dependencies
|
57
|
+
* container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
|
58
|
+
* container.bind<IMongoDBConnector>(MongoDBConnector).toSelf().inSingletonScope();
|
59
|
+
* container.bind<Root>(Root).toSelf().inSingletonScope();
|
60
|
+
*
|
61
|
+
* // Configure
|
62
|
+
* container.get<IConfig>(Types.Config).merge({
|
63
|
+
* MongoDB: [
|
64
|
+
* {
|
65
|
+
* name: 'connection',
|
66
|
+
* host: 'mongodb://localhost:27017/',
|
67
|
+
* options: {
|
68
|
+
* useNewUrlParser: true,
|
69
|
+
* useUnifiedTopology: true,
|
70
|
+
* dbName: 'test',
|
71
|
+
* },
|
72
|
+
* },
|
73
|
+
* ],
|
74
|
+
* });
|
75
|
+
*
|
76
|
+
* (async () => {
|
77
|
+
* const root = container.get<Root>(Root);
|
78
|
+
* await root.$run();
|
79
|
+
* await root.connector.connection().dropDatabase();
|
80
|
+
*
|
81
|
+
* const connection = root.connector.connection('connection'); // Get connection instance
|
82
|
+
* console.log(connection);
|
83
|
+
*
|
84
|
+
* await new root.test({
|
85
|
+
* firstName: 'Vasya',
|
86
|
+
* lastName: 'Pupkin',
|
87
|
+
* age: 36,
|
88
|
+
* }).save(); // insert data into test collection
|
89
|
+
*
|
90
|
+
* // Get data from database
|
91
|
+
* const data = await root.test.find({ firstName: 'Vasya' }, { _id: 0 });
|
92
|
+
* console.log(data); // {
|
93
|
+
* // firstName: 'Vasya',
|
94
|
+
* // lastName: 'Pupkin',
|
95
|
+
* // age: 36,
|
96
|
+
* // }
|
97
|
+
* })();
|
98
|
+
* ```
|
99
|
+
*/
|
100
|
+
@injectable()
|
101
|
+
export class MongoDBConnector extends Connector<IMongoDBConfig, IMongoDBConnection> {
|
102
|
+
/**
|
103
|
+
* @description Namespace path for fetching configuration
|
104
|
+
*/
|
105
|
+
protected readonly namespace = 'MongoDB';
|
106
|
+
/**
|
107
|
+
* @description Create connection
|
108
|
+
*/
|
109
|
+
protected async connect(config: IMongoDBConfig) {
|
110
|
+
let connection;
|
111
|
+
try {
|
112
|
+
connection = createConnection(config.host, config.options);
|
113
|
+
await events.once(connection, 'open');
|
114
|
+
} catch (e) {
|
115
|
+
throw new MongoDBCantConnectError(e);
|
116
|
+
}
|
117
|
+
return connection;
|
118
|
+
}
|
119
|
+
/**
|
120
|
+
* @description Initialize method
|
121
|
+
*/
|
122
|
+
@init() protected async initialize() {
|
123
|
+
connections = this.connections;
|
124
|
+
await super.initialize();
|
125
|
+
}
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* @description Private connections link
|
129
|
+
*/
|
130
|
+
let connections: Map<string, IMongoDBConnection> = null;
|
131
|
+
/**
|
132
|
+
* @description Model injection decorator
|
133
|
+
*/
|
134
|
+
export const model = <T = unknown>(
|
135
|
+
Model: new (...args: any) => T,
|
136
|
+
connection?: string,
|
137
|
+
options: Record<string, unknown> = {},
|
138
|
+
) => {
|
139
|
+
return (proto?: any, key?: string) => {
|
140
|
+
Object.defineProperty(proto, key, {
|
141
|
+
get() {
|
142
|
+
return getModelForClass(Model, {
|
143
|
+
existingConnection: connection
|
144
|
+
? connections.get(connection)
|
145
|
+
: [...connections][0][1],
|
146
|
+
options,
|
147
|
+
});
|
148
|
+
},
|
149
|
+
configurable: false,
|
150
|
+
});
|
151
|
+
};
|
152
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { IConnectorConfig, IConnector } from '@biorate/connector';
|
2
|
+
import { ConnectOptions, Connection } from 'mongoose';
|
3
|
+
|
4
|
+
export type IMongoDBConnection = Connection;
|
5
|
+
|
6
|
+
export interface IMongoDBConfig extends IConnectorConfig {
|
7
|
+
host: string;
|
8
|
+
options: ConnectOptions;
|
9
|
+
}
|
10
|
+
|
11
|
+
export type IMongoDBConnector = IConnector<IMongoDBConfig, IMongoDBConnection>;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { use } from 'chai';
|
2
|
+
import { jestSnapshotPlugin } from 'mocha-chai-jest-snapshot';
|
3
|
+
import { inject, container, Types, Core } from '@biorate/inversion';
|
4
|
+
import { IConfig, Config } from '@biorate/config';
|
5
|
+
import { MongoDBConnector, IMongoDBConnector, model } from '../../src';
|
6
|
+
import { ReturnModelType } from '@typegoose/typegoose';
|
7
|
+
import { TestModel } from './models';
|
8
|
+
|
9
|
+
export * from './models';
|
10
|
+
|
11
|
+
use(jestSnapshotPlugin());
|
12
|
+
|
13
|
+
export const dbName = 'test';
|
14
|
+
|
15
|
+
export class Root extends Core() {
|
16
|
+
@inject(MongoDBConnector) public connector: IMongoDBConnector;
|
17
|
+
@model(TestModel) public test: ReturnModelType<typeof TestModel>;
|
18
|
+
}
|
19
|
+
|
20
|
+
container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
|
21
|
+
container.bind<IMongoDBConnector>(MongoDBConnector).toSelf().inSingletonScope();
|
22
|
+
container.bind<Root>(Root).toSelf().inSingletonScope();
|
23
|
+
|
24
|
+
container.get<IConfig>(Types.Config).merge({
|
25
|
+
MongoDB: [
|
26
|
+
{
|
27
|
+
name: 'connection',
|
28
|
+
host: 'mongodb://localhost:27017/',
|
29
|
+
options: {
|
30
|
+
useNewUrlParser: true,
|
31
|
+
useUnifiedTopology: true,
|
32
|
+
dbName,
|
33
|
+
},
|
34
|
+
},
|
35
|
+
],
|
36
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './test';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Severity, modelOptions, Prop } from '@typegoose/typegoose';
|
2
|
+
|
3
|
+
@modelOptions({
|
4
|
+
options: {
|
5
|
+
allowMixed: Severity.ALLOW,
|
6
|
+
},
|
7
|
+
schemaOptions: { collection: 'test', versionKey: false },
|
8
|
+
})
|
9
|
+
export class TestModel {
|
10
|
+
@Prop()
|
11
|
+
firstName: string;
|
12
|
+
|
13
|
+
@Prop()
|
14
|
+
lastName: string;
|
15
|
+
|
16
|
+
@Prop()
|
17
|
+
age: number;
|
18
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`@biorate/mongodb connection access 1`] = `"test"`;
|
4
|
+
|
5
|
+
exports[`@biorate/mongodb get from test collection 1`] = `
|
6
|
+
Array [
|
7
|
+
Object {
|
8
|
+
"age": 36,
|
9
|
+
"firstName": "Vasya",
|
10
|
+
"lastName": "Pupkin",
|
11
|
+
},
|
12
|
+
]
|
13
|
+
`;
|
14
|
+
|
15
|
+
exports[`@biorate/mongodb insert into test collection 1`] = `
|
16
|
+
Object {
|
17
|
+
"age": 36,
|
18
|
+
"firstName": "Vasya",
|
19
|
+
"lastName": "Pupkin",
|
20
|
+
}
|
21
|
+
`;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { expect } from 'chai';
|
2
|
+
import { container } from '@biorate/inversion';
|
3
|
+
import { Root, TestModel } from './__mocks__';
|
4
|
+
|
5
|
+
describe('@biorate/mongodb', function () {
|
6
|
+
let root: Root;
|
7
|
+
this.timeout(3e4);
|
8
|
+
|
9
|
+
before(async () => {
|
10
|
+
root = container.get<Root>(Root);
|
11
|
+
await root.$run();
|
12
|
+
await root.connector.connection().dropDatabase();
|
13
|
+
});
|
14
|
+
|
15
|
+
after(async () => {
|
16
|
+
await root.connector.connection().dropDatabase();
|
17
|
+
});
|
18
|
+
|
19
|
+
it('connection access', () =>
|
20
|
+
expect(root.connector.connection('connection').name).toMatchSnapshot());
|
21
|
+
|
22
|
+
it('insert into test collection', async () => {
|
23
|
+
const data = await new root.test({
|
24
|
+
firstName: 'Vasya',
|
25
|
+
lastName: 'Pupkin',
|
26
|
+
age: 36,
|
27
|
+
}).save();
|
28
|
+
expect({
|
29
|
+
firstName: data.firstName,
|
30
|
+
lastName: data.lastName,
|
31
|
+
age: data.age,
|
32
|
+
}).toMatchSnapshot();
|
33
|
+
});
|
34
|
+
|
35
|
+
it('get from test collection', async () =>
|
36
|
+
expect(await root.test.find({ firstName: 'Vasya' }, { _id: 0 })).toMatchSnapshot());
|
37
|
+
});
|