Skip to content

Instantly share code, notes, and snippets.

@calebkleveter
Last active September 2, 2019 20:22
Show Gist options
  • Save calebkleveter/e5b7384f967edf1185f82fdef866aef4 to your computer and use it in GitHub Desktop.
Save calebkleveter/e5b7384f967edf1185f82fdef866aef4 to your computer and use it in GitHub Desktop.
extension Property {
final class Model: FluentKit.Model, AutoMigrating {
static let schema: String = "properties"
@FluentKit.ID(key: "id") var id: UUID?
@Parent(key: "preset") var preset: PropertyPreset.Model
// These are the ploymorphic properties that connect a given `Property` model row
// to any other model row. If we only want the parent to have a single `Property`, we
// can mark the `parent` field as `UINIQUE`.
@Field(key: "parent") var parent: UUID?
@Field(key: "parent_type") var parentType: String?
// Other properties go here...
@Field(key: "key") var key: String
@Field(key: "value") var value: PropertyValue<Property>
init() { }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment