owservable 0.8.13 → 0.8.14
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
export default class MongoDBConnector {
|
|
3
|
-
static init(mongoDbUri: string): Promise<
|
|
3
|
+
static init(mongoDbUri: string): Promise<Connection>;
|
|
4
4
|
static get connection(): Connection;
|
|
5
5
|
private static _connection;
|
|
6
6
|
private constructor();
|
|
@@ -15,20 +15,22 @@ class MongoDBConnector {
|
|
|
15
15
|
static init(mongoDbUri) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
if (!this._connection) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
console.log('ows -> MongoDB connecting to', mongoDbUri);
|
|
20
|
+
mongoose
|
|
21
|
+
.connect(mongoDbUri, {
|
|
22
|
+
poolSize: 10,
|
|
23
|
+
useNewUrlParser: true,
|
|
24
|
+
useUnifiedTopology: true
|
|
25
|
+
})
|
|
26
|
+
.then(() => {
|
|
27
|
+
this._connection = mongoose.connection;
|
|
28
|
+
this._connection.on('error', console.error.bind(console, 'ows -> MongoDB connection error:'));
|
|
29
|
+
this._connection.once('open', () => console.log('ows -> MongoDB connected to', mongoDbUri));
|
|
30
|
+
resolve(this._connection);
|
|
31
|
+
})
|
|
32
|
+
.catch(reject);
|
|
33
|
+
}));
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
36
|
return this._connection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.connector.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.connector.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;AAEb,qCAAqC;AAGrC,MAAqB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"mongodb.connector.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.connector.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;AAEb,qCAAqC;AAGrC,MAAqB,gBAAgB;IAkCpC,gBAAuB,CAAC;IAjCjB,MAAM,CAAO,IAAI,CAAC,UAAkB;;YAC1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBACtB,OAAO,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;oBAC5C,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,UAAU,CAAC,CAAC;oBACxD,QAAQ;yBACN,OAAO,CAAC,UAAU,EAAE;wBACpB,QAAQ,EAAE,EAAE;wBAEZ,eAAe,EAAE,IAAI;wBACrB,kBAAkB,EAAE,IAAI;qBACxB,CAAC;yBACD,IAAI,CAAC,GAAG,EAAE;wBACV,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC;wBACvC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC,CAAC;wBAC9F,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,UAAU,CAAC,CAAC,CAAC;wBAE5F,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC3B,CAAC,CAAC;yBACD,KAAK,CAAC,MAAM,CAAC,CAAC;gBACjB,CAAC,CAAA,CAAC,CAAC;aAGH;iBAAM;gBACN,OAAO,IAAI,CAAC,WAAW,CAAC;aACxB;QACF,CAAC;KAAA;IAEM,MAAM,KAAK,UAAU;QAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CAKD;AAnCD,mCAmCC"}
|