Skip to content

Commit

Permalink
Add unidirectional support to the generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Mar 25, 2021
1 parent a8c6009 commit 0a214f2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions generators/entity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,23 @@ class EntityGenerator extends BaseBlueprintGenerator {
relationship.otherEntity = otherEntity;
otherEntity.otherRelationships = otherEntity.otherRelationships || [];
otherEntity.otherRelationships.push(relationship);

if (
relationship.unidirectional &&
(relationship.relationshipType === 'many-to-many' ||
// OneToOne is back reference is require due to filtering
relationship.relationshipType === 'one-to-one' ||
(relationship.relationshipType === 'one-to-many' && !this.context.databaseTypeNeo4j))
) {
relationship.otherEntityRelationshipName = _.lowerFirst(this.context.name);
otherEntity.relationships.push({
otherEntityName: relationship.otherEntityRelationshipName,
ownerSide: !relationship.ownerSide,
otherEntityRelationshipName: relationship.relationshipName,
relationshipName: relationship.otherEntityRelationshipName,
relationshipType: relationship.relationshipType.split('-').reverse().join('-'),
});
}
});
},

Expand Down

0 comments on commit 0a214f2

Please sign in to comment.