@reldens/storage 0.10.0-beta.37 → 0.10.0-beta.38
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.
|
@@ -232,11 +232,11 @@ class MikroOrmDriver extends BaseDriver
|
|
|
232
232
|
async appendRelationsToCollection(entitiesCollection, relations)
|
|
233
233
|
{
|
|
234
234
|
// @TODO - BETA - Refactor. I would like to use populate but it may not work if the driver is not Mongo DB.
|
|
235
|
-
if(typeof this.rawModel.entity.
|
|
235
|
+
if(typeof this.rawModel.entity.relationMappings !== 'function'){
|
|
236
236
|
return entitiesCollection;
|
|
237
237
|
}
|
|
238
238
|
if(!sc.isArray(relations) || 0 === relations.length){
|
|
239
|
-
relations = Object.keys(this.rawModel.entity.
|
|
239
|
+
relations = Object.keys(this.rawModel.entity.relationMappings() || {});
|
|
240
240
|
}
|
|
241
241
|
if(0 === relations.length){
|
|
242
242
|
return entitiesCollection;
|
|
@@ -250,12 +250,12 @@ class MikroOrmDriver extends BaseDriver
|
|
|
250
250
|
async appendRelatedEntities(entity, relations)
|
|
251
251
|
{
|
|
252
252
|
// @TODO - BETA - Refactor and improve.
|
|
253
|
-
if(typeof this.rawModel.entity.
|
|
253
|
+
if(typeof this.rawModel.entity.relationMappings !== 'function'){
|
|
254
254
|
return entity;
|
|
255
255
|
}
|
|
256
|
-
let
|
|
256
|
+
let relationMappings = this.rawModel.entity.relationMappings();
|
|
257
257
|
for(let i of relations){
|
|
258
|
-
let relation =
|
|
258
|
+
let relation = relationMappings[i];
|
|
259
259
|
let relationRepository = this.server.getEntity(relation.entityName);
|
|
260
260
|
let isManyToOne = 'm:1' === relation.reference;
|
|
261
261
|
let isOneToMany = '1:m' === relation.reference;
|
|
@@ -271,13 +271,13 @@ class MikroOrmDriver extends BaseDriver
|
|
|
271
271
|
|
|
272
272
|
async createNested(newInstance, params)
|
|
273
273
|
{
|
|
274
|
-
if(typeof this.rawModel.entity.
|
|
274
|
+
if(typeof this.rawModel.entity.relationMappings !== 'function'){
|
|
275
275
|
return false;
|
|
276
276
|
}
|
|
277
|
-
let
|
|
278
|
-
for(let i of Object.keys(
|
|
277
|
+
let relationMappings = this.rawModel.entity.relationMappings();
|
|
278
|
+
for(let i of Object.keys(relationMappings)){
|
|
279
279
|
// @TODO - BETA - Refactor and improve.
|
|
280
|
-
let relationData =
|
|
280
|
+
let relationData = relationMappings[i];
|
|
281
281
|
let relationEntity = this.server.entityManager.get(relationData.entityName).rawModel.entity;
|
|
282
282
|
if(!relationEntity){
|
|
283
283
|
Logger.warning('Factory not found for relation definition:', relationData);
|