Added the catalogue models and seed to support phase 6 of the POC prototype in the Persistence package.

This commit is contained in:
javier committed 2026-09-21 13:52:52 +02:00
1 parent 31d2d98d49
commit 256d22df40
10 files changed
+473 -4

No files matched your search

@@ -0,0 +1,103 @@
import FluentKit
import Foundation
/// A FluentKit model of a single `events` row: a con where shops trade in person.
final class EventRecord: Model, @unchecked Sendable {
// MARK: Properties
static let schema = "events"
@ID(key: .id)
var id: UUID?
@Field(key: "slug")
var slug: String
@Field(key: "name")
var name: String
@Field(key: "venue")
var venue: String
@Field(key: "starts_on")
var startsOn: Date
@Field(key: "ends_on")
var endsOn: Date
@Siblings(through: EventShopRecord.self, from: \.$event, to: \.$shop)
var shops: [ShopRecord]
// MARK: Initializers
init() {}
init(
_ event: Event
) {
self.slug = event.slug
self.name = event.name
self.venue = event.venue
self.startsOn = event.startsOn
self.endsOn = event.endsOn
}
}
/// A FluentKit model of a single `event_shops` row: a shop trading at an event.
final class EventShopRecord: Model, @unchecked Sendable {
// MARK: Properties
static let schema = "event_shops"
@ID(key: .id)
var id: UUID?
@Parent(key: "event_id")
var event: EventRecord
@Parent(key: "shop_id")
var shop: ShopRecord
// MARK: Initializers
init() {}
}
/// A FluentKit model of a single `owned_issues` row: an issue of a series in an account's collection.
final class OwnedIssueRecord: Model, @unchecked Sendable {
// MARK: Properties
static let schema = "owned_issues"
@ID(key: .id)
var id: UUID?
@Parent(key: "user_id")
var user: UserRecord
@Field(key: "series_slug")
var seriesSlug: String
@Field(key: "issue")
var issue: Int
// MARK: Initializers
init() {}
init(
userID: UUID,
seriesSlug: String,
issue: Int
) {
self.$user.id = userID
self.seriesSlug = seriesSlug
self.issue = issue
}
}