File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ function byPrimaryKey(model) {
4040 * @return {Object }
4141 */
4242function createRelationshipObject ( include , item ) {
43- const relatedModelIdAttribute = include . association . sourceIdentifier ; //Object.keys(include.model.attributes).filter(byPrimaryKey(include.model))[0] ;
43+ const relatedModelIdAttribute = include . association . targetKey ;
4444 const associationValue = item [ include . as ] ;
45- if ( Array . isArray ( associationValue ) ) {
45+ if ( associationValue && Array . isArray ( associationValue ) ) {
4646 const results = [ ] ;
4747 associationValue . forEach ( function ( record ) {
4848 const relatedItem = { } ;
@@ -51,7 +51,7 @@ function createRelationshipObject(include, item) {
5151 results . push ( relatedItem ) ;
5252 } ) ;
5353 return results ;
54- } else if ( typeof associationValue === 'object' ) {
54+ } else if ( associationValue && typeof associationValue === 'object' ) {
5555 const relatedItem = { } ;
5656 relatedItem . type = include . model . name ;
5757 relatedItem [ relatedModelIdAttribute ] = associationValue [ relatedModelIdAttribute ] ;
You can’t perform that action at this time.
0 commit comments