Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit e6b3651

Browse files
committed
fix: removeRelationship() removes onlyOne relationship too.
1 parent 18a604f commit e6b3651

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/library/resource.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,15 @@ export class Resource extends ParentResourceService implements IResource {
240240
if (!('data' in this.relationships[type_alias])) {
241241
return false;
242242
}
243-
if (!(id in this.relationships[type_alias]['data'])) {
244-
return false;
243+
244+
if (type_alias in this.getService().schema.relationships && this.getService().schema.relationships[type_alias].hasMany) {
245+
if (!(id in this.relationships[type_alias]['data'])) {
246+
return false;
247+
}
248+
delete this.relationships[type_alias]['data'][id];
249+
} else {
250+
this.relationships[type_alias]['data'] = { };
245251
}
246-
delete this.relationships[type_alias]['data'][id];
247252
return true;
248253
}
249254

0 commit comments

Comments
 (0)