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 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
- dataSource = createDataBaseSource();
180
- if (!!dataSource.isInitialized) return [3 /*break*/, 2];
181
- return [4 /*yield*/, dataSource.initialize()];
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*/, new _1.CustomRepository(entity, dataSource)];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "2.2.9",
3
+ "version": "2.3.1",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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
- const dataSource = createDataBaseSource()
113
- if (!dataSource.isInitialized) {
114
- await dataSource.initialize()
112
+ if (!connection) {
113
+ connection = createDataBaseSource()
114
+ await connection.initialize()
115
115
  }
116
- return new CustomRepository(entity, dataSource)
116
+ return connection
117
+ .getRepository(entity)
118
+ .extend(CustomRepository.prototype) as CustomRepository<T>
117
119
  }