Files
procons/Sources/App/Models/ProCon.swift
2024-12-31 17:02:29 -05:00

41 lines
617 B
Swift

import Fluent
import Foundation
import Vapor
final class ProCon: Model {
static let schema = "procon"
@ID(key: .id)
var id: UUID?
@Parent(key: "userId")
var user: User
@Field(key: "description")
var description: String
@Field(key: "type")
var type: ProConType
init() {}
init(
id: UUID? = nil,
type: ProConType,
description: String,
userId: User.IDValue
) {
self.id = id
self.type = type
self.description = description
$user.id = userId
}
enum ProConType: String, Codable, Equatable, Sendable {
case pro, con
}
}
extension ProCon: Content {}