Last active
August 15, 2019 13:49
-
-
Save dmytro-anokhin/dda6b5ec0e58d4370a3e65b7f35b5d25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let modelDescription = CoreDataModelDescription( | |
| entities: [ | |
| .entity( | |
| name: "Author", | |
| managedObjectClass: Author.self, | |
| attributes: [ | |
| .attribute(name: "name", type: .stringAttributeType) | |
| ], | |
| relationships: [ | |
| .relationship(name: "publications", destination: "Publication", toMany: true, deleteRule: .cascadeDeleteRule, inverse: "author") | |
| ]), | |
| .entity( | |
| name: "Publication", | |
| managedObjectClass: Publication.self, | |
| attributes: [ | |
| .attribute(name: "publicationDate", type: .dateAttributeType), | |
| .attribute(name: "numberOfViews", type: .integer64AttributeType, isOptional: true) | |
| ], | |
| relationships: [ | |
| .relationship(name: "author", destination: "Author", toMany: false, inverse: "publications") | |
| ]), | |
| .entity( | |
| name: "Article", | |
| managedObjectClass: Article.self, | |
| parentEntity: "Publication", | |
| attributes: [ | |
| .attribute(name: "text", type: .stringAttributeType) | |
| ]) | |
| ] | |
| ) | |
| let model = modelDescription.makeMode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment