gloss-ios/SelectedRibbon.swift

52 lines
1.4 KiB
Swift
Raw Normal View History

2023-02-28 14:03:58 -08:00
//
// Ribbon.swift
// gloss
//
// Created by Saint on 2/24/23.
//
import GRDB
/// The Line struct.
///
/// Identifiable conformance supports SwiftUI list animations, and type-safe
/// GRDB primary key methods.
/// Equatable conformance supports tests.
struct SelectedRibbon: Identifiable, Equatable {
/// The player id.
///
/// Int64 is the recommended type for auto-incremented database ids.
/// Use nil for players that are not inserted yet in the database.
var id: Int64?
2024-05-27 19:28:13 -07:00
var ribbonGroupId: Int64
2023-02-28 14:03:58 -08:00
}
extension SelectedRibbon {
}
// MARK: - Persistence
/// Make Line a Codable Record.
///
/// See <https://github.com/groue/GRDB.swift/blob/master/README.md#records>
extension SelectedRibbon: Codable, FetchableRecord, MutablePersistableRecord {
// Define database columns from CodingKeys
fileprivate enum Columns {
static let id = Column(CodingKeys.id)
static let ribbonId = Column(CodingKeys.ribbonId)
}
2024-05-27 19:28:13 -07:00
2023-02-28 14:03:58 -08:00
/// Updates a player id after it has been inserted in the database.
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
// MARK: - Line Database Requests
/// Define some player requests used by the application.
///
/// See <https://github.com/groue/GRDB.swift/blob/master/README.md#requests>
/// See <https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md>
extension DerivableRequest<SelectedRibbon> {
}