test-entity-library-asm 2.2.9 → 2.3.1
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/index.js +6 -5
- package/package.json +1 -1
- package/src/index.ts +6 -4
package/dist/index.js
CHANGED
|
@@ -172,17 +172,18 @@ function getTimeZone() {
|
|
|
172
172
|
}
|
|
173
173
|
exports.getTimeZone = getTimeZone;
|
|
174
174
|
var getRepositoryByEntity = function (entity) { return __awaiter(void 0, void 0, void 0, function () {
|
|
175
|
-
var dataSource;
|
|
176
175
|
return __generator(this, function (_a) {
|
|
177
176
|
switch (_a.label) {
|
|
178
177
|
case 0:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return [4 /*yield*/,
|
|
178
|
+
if (!!connection) return [3 /*break*/, 2];
|
|
179
|
+
connection = createDataBaseSource();
|
|
180
|
+
return [4 /*yield*/, connection.initialize()];
|
|
182
181
|
case 1:
|
|
183
182
|
_a.sent();
|
|
184
183
|
_a.label = 2;
|
|
185
|
-
case 2: return [2 /*return*/,
|
|
184
|
+
case 2: return [2 /*return*/, connection
|
|
185
|
+
.getRepository(entity)
|
|
186
|
+
.extend(_1.CustomRepository.prototype)];
|
|
186
187
|
}
|
|
187
188
|
});
|
|
188
189
|
}); };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -109,9 +109,11 @@ export function getTimeZone(): string {
|
|
|
109
109
|
export const getRepositoryByEntity = async <T extends ObjectLiteral>(
|
|
110
110
|
entity: EntityTarget<T>
|
|
111
111
|
): Promise<CustomRepository<T>> => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
await
|
|
112
|
+
if (!connection) {
|
|
113
|
+
connection = createDataBaseSource()
|
|
114
|
+
await connection.initialize()
|
|
115
115
|
}
|
|
116
|
-
return
|
|
116
|
+
return connection
|
|
117
|
+
.getRepository(entity)
|
|
118
|
+
.extend(CustomRepository.prototype) as CustomRepository<T>
|
|
117
119
|
}
|