68 lines
1.2 KiB
Swift
68 lines
1.2 KiB
Swift
import FluentKit
|
|
import Foundation
|
|
|
|
/// A FluentKit model of a single `series` row: a run of issues in the catalogue.
|
|
final class SeriesRecord: Model, @unchecked Sendable {
|
|
|
|
// MARK: Properties
|
|
|
|
static let schema = "series"
|
|
|
|
@ID(key: .id)
|
|
var id: UUID?
|
|
|
|
@Field(key: "slug")
|
|
var slug: String
|
|
|
|
@Field(key: "name")
|
|
var name: String
|
|
|
|
@Field(key: "publisher")
|
|
var publisher: String
|
|
|
|
@Field(key: "years")
|
|
var years: String
|
|
|
|
@Field(key: "issue_count")
|
|
var issueCount: Int
|
|
|
|
@Field(key: "blurb")
|
|
var blurb: String
|
|
|
|
// MARK: Initializers
|
|
|
|
init() {}
|
|
|
|
init(
|
|
_ series: Series
|
|
) {
|
|
self.slug = series.slug
|
|
self.name = series.name
|
|
self.publisher = series.publisher
|
|
self.years = series.years
|
|
self.issueCount = series.issueCount
|
|
self.blurb = series.blurb
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Extensions
|
|
|
|
extension SeriesRecord {
|
|
|
|
// MARK: Computed
|
|
|
|
/// The `Sendable` snapshot of the record.
|
|
var snapshot: Series {
|
|
.init(
|
|
slug: slug,
|
|
name: name,
|
|
publisher: publisher,
|
|
years: years,
|
|
issueCount: issueCount,
|
|
blurb: blurb
|
|
)
|
|
}
|
|
|
|
}
|