41 lines
617 B
Swift
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 {}
|