Skip to content

Commit

Permalink
Add check on data length parsing the HasMany relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
ghidoz committed Sep 22, 2016
1 parent 21ebac8 commit 0b9ac31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/models/json-api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export class JsonApiModel {
if (hasMany) {
for (let metadata of hasMany){
let relationship: any = data.relationships[metadata.relationship];
if (relationship && relationship.data) {
if (relationship && relationship.data && relationship.data.length > 0) {
console.log(relationship, this);
let typeName: string = relationship.data[0].type;
let modelType: ModelType = Reflect.getMetadata('JsonApiDatastoreConfig', this._datastore.constructor).models[typeName];
let relationshipModel: JsonApiModel[] = this.getHasManyRelationship(modelType, relationship.data, included,typeName, level);
Expand Down

0 comments on commit 0b9ac31

Please sign in to comment.