feat: Initial commit
This commit is contained in:
1039
Sources/App/Models/BadWords.swift
Normal file
1039
Sources/App/Models/BadWords.swift
Normal file
File diff suppressed because it is too large
Load Diff
40
Sources/App/Models/ProCon.swift
Normal file
40
Sources/App/Models/ProCon.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
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 {}
|
||||
25
Sources/App/Models/User.swift
Normal file
25
Sources/App/Models/User.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
import Fluent
|
||||
import Foundation
|
||||
import Vapor
|
||||
|
||||
final class User: Model {
|
||||
static let schema = "user"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "displayName")
|
||||
var displayName: String
|
||||
|
||||
@Children(for: \.$user)
|
||||
var prosAndCons: [ProCon]
|
||||
|
||||
init() {}
|
||||
|
||||
init(id: UUID? = nil, displayName: String) {
|
||||
self.id = id
|
||||
self.displayName = displayName
|
||||
}
|
||||
}
|
||||
|
||||
extension User: Content {}
|
||||
Reference in New Issue
Block a user