How to flatten multi-level nested objects


#1

Is there a way to flatten to multiple rows one row that have many levels of nested types?

For example, the following command returns a long tree all in one row:

var org = Organization.get(organizationId, "denormChildren.(startsWith(relationship, 'PREL:OROL')).to.roles.assetMappings.((typeIdent == 'FAPR:FAOW') && (!exists(start) || now()>=start) && (!exists(end) || now()<=end)).asset");

The result is something ugly as this and it’s processing is very painful:

 { ... }
 denormChildren: [ ... ]
 0: { ... }
 id: 9ace767b18b6616b17154a713615902b
 to: { ... }
 id: 1
 version: 5242881
 roles: [ ... ]
 0: { ... }
 party: { ... }
 id: 1
 id: 1_CUST
 version: 1376257
 typeIdent: PR:CUS
 1: { ... }
 party: { ... }
 id: 1
 assetMappings: [ ... ]
 0: { ... }
 asset: { ... }
 HDDBase: 20
 CDDBase: 26
 id: 10
 partyRole: { ... }
 id: 1_DEPT
 location: { ... }
 id: PREM_10
 id: 1_10
 version: 327685
 name: couscous
 typeIdent: FAPR:FAOW
 from: { ... }
 HDDBase: 20
 CDDBase: 26
 id: 10
 to: { ... }
 id: 1_DEPT
 start: 2018-04-02T13:16:13.000+02:00
 end: 2018-04-16T13:16:20.000+02:00
 id: 1_DEPT
 version: 65537
 typeIdent: PR:DPT
 typeIdent: PRT:ORG
 id: 1
 version: 5242881
 typeIdent: PRT:ORG