sourcery-templates icon indicating copy to clipboard operation
sourcery-templates copied to clipboard

Automatically create relations

Open steffendsommer opened this issue 6 years ago • 2 comments

Since we're already annotating relations, I think it makes sense to have Sourcery create relations. E.g. in the case of (inside Employee.swift):

// sourcery: preparation = foreignId, unique = false, foreignTable = Company
internal var companyId: Identifier?

Then it could create an extension on Employee with a property called company which would return the parent. Similarly it could create an extension on Company with a property called employees which would return the children.

We could consider if it makes sense to have an annotation to indicate 1-1 relations so instead of returning all the children it would return the first children.

steffendsommer avatar Oct 04 '17 08:10 steffendsommer