Files
cod-backend/Sources/App/Models/Game.swift

54 lines
874 B
Swift

//
// Game.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
final class Game: Model, Content {
// Name of the table or collection.
static let schema = "game"
@ID(key: .id)
var id: UUID?
@Field(key: "game_id")
var gameId: String
@Field(key: "name")
var name: String
@Field(key: "maps")
var maps: String
@Field(key: "enabled")
var enabled: Bool
// Creates a new, empty .
init() { }
// Creates a new with all properties set.
init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool) {
self.id = id
self.gameId = gameId
self.name = name
self.maps = maps
self.enabled = enabled
}
var mapIds:[Int] {
maps.components(separatedBy: ",").map{Int($0)!}
}
}