@onehat/data 1.7.15 → 1.7.16
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/package.json
CHANGED
|
@@ -274,8 +274,9 @@ export default class Repository extends EventEmitter {
|
|
|
274
274
|
this._createMethods();
|
|
275
275
|
this._createStatics();
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
const init = this.schema.repository.init || this.originalConfig.init; // The latter is mainly for lfr repositories
|
|
278
|
+
if (init) {
|
|
279
|
+
await init.call(this);
|
|
279
280
|
}
|
|
280
281
|
|
|
281
282
|
this.isInitialized = true;
|
|
@@ -290,7 +291,7 @@ export default class Repository extends EventEmitter {
|
|
|
290
291
|
if (this.isDestroyed) {
|
|
291
292
|
throw Error('this._createMethods is no longer valid. Repository has been destroyed.');
|
|
292
293
|
}
|
|
293
|
-
const methodDefinitions = this.schema.repository.methods;
|
|
294
|
+
const methodDefinitions = this.schema.repository.methods || this.originalConfig.methods; // The latter is mainly for lfr repositories
|
|
294
295
|
if (!_.isEmpty(methodDefinitions)) {
|
|
295
296
|
_.each(methodDefinitions, (method, name) => {
|
|
296
297
|
this[name] = method; // NOTE: Methods must be defined in schema as "function() {}", not as "() => {}" so "this" will be assigned correctly
|
|
@@ -306,7 +307,7 @@ export default class Repository extends EventEmitter {
|
|
|
306
307
|
if (this.isDestroyed) {
|
|
307
308
|
throw Error('this._createStatics is no longer valid. Entity has been destroyed.');
|
|
308
309
|
}
|
|
309
|
-
const staticsDefinitions = this.schema.repository.statics;
|
|
310
|
+
const staticsDefinitions = this.schema.repository.statics || this.originalConfig.statics; // The latter is mainly for lfr repositories
|
|
310
311
|
if (!_.isEmpty(staticsDefinitions)) {
|
|
311
312
|
_.each(staticsDefinitions, (value, key) => {
|
|
312
313
|
this[key] = value;
|