owservable 0.8.11 → 0.8.12
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,8 +1,7 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
export default class MongoDBConnector {
|
|
3
|
-
static init(mongoDbUri: string): Connection
|
|
3
|
+
static init(mongoDbUri: string): Promise<Connection>;
|
|
4
4
|
static get connection(): Connection;
|
|
5
|
-
private static
|
|
6
|
-
private readonly _connection;
|
|
5
|
+
private static _connection;
|
|
7
6
|
private constructor();
|
|
8
7
|
}
|
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const mongoose = require("mongoose");
|
|
4
13
|
class MongoDBConnector {
|
|
5
|
-
constructor(
|
|
6
|
-
mongoose
|
|
7
|
-
.connect(mongoDbUri, {
|
|
8
|
-
poolSize: 10,
|
|
9
|
-
useNewUrlParser: true,
|
|
10
|
-
useUnifiedTopology: true
|
|
11
|
-
})
|
|
12
|
-
.then(() => ({}))
|
|
13
|
-
.catch(console.error);
|
|
14
|
-
this._connection = mongoose.connection;
|
|
15
|
-
this._connection.on('error', console.error.bind(console, 'connection error:'));
|
|
16
|
-
this._connection.once('open', () => console.log('ows -> MongoDB connected to', mongoDbUri));
|
|
17
|
-
}
|
|
14
|
+
constructor() { }
|
|
18
15
|
static init(mongoDbUri) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!this._connection) {
|
|
18
|
+
mongoose
|
|
19
|
+
.connect(mongoDbUri, {
|
|
20
|
+
poolSize: 10,
|
|
21
|
+
useNewUrlParser: true,
|
|
22
|
+
useUnifiedTopology: true
|
|
23
|
+
})
|
|
24
|
+
.then(() => {
|
|
25
|
+
this._connection = mongoose.connection;
|
|
26
|
+
this._connection.on('error', console.error.bind(console, 'connection error:'));
|
|
27
|
+
this._connection.once('open', () => console.log('ows -> MongoDB connected to', mongoDbUri));
|
|
28
|
+
return this._connection;
|
|
29
|
+
})
|
|
30
|
+
.catch(console.error);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this._connection;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
22
36
|
}
|
|
23
37
|
static get connection() {
|
|
24
|
-
return
|
|
38
|
+
return this._connection;
|
|
25
39
|
}
|
|
26
40
|
}
|
|
27
41
|
exports.default = MongoDBConnector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.connector.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.connector.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"mongodb.connector.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.connector.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;AAEb,qCAAqC;AAGrC,MAAqB,gBAAgB;IA+BpC,gBAAuB,CAAC;IA9BjB,MAAM,CAAO,IAAI,CAAC,UAAkB;;YAC1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBACtB,QAAQ;qBACN,OAAO,CAAC,UAAU,EAAE;oBACpB,QAAQ,EAAE,EAAE;oBAEZ,eAAe,EAAE,IAAI;oBACrB,kBAAkB,EAAE,IAAI;iBACxB,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE;oBACV,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC;oBACvC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;oBAC/E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,UAAU,CAAC,CAAC,CAAC;oBAE5F,OAAO,IAAI,CAAC,WAAW,CAAC;gBACzB,CAAC,CAAC;qBACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAGvB;iBAAM;gBACN,OAAO,IAAI,CAAC,WAAW,CAAC;aACxB;QACF,CAAC;KAAA;IAEM,MAAM,KAAK,UAAU;QAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CAKD;AAhCD,mCAgCC"}
|