// // Post.swift // // // Created by Mario on 04/10/22. // import Fluent import Vapor struct PostRequest: Codable { var content: String var title: String var pub: Bool? } struct PostSummary: Codable, Content { var id: UUID var title: String var pub: Bool var created_at: Int var whitelist: String } final class Post: Model, Content { static let schema = "exploits" @ID(key: .id) var id: UUID? @Field(key: "created_by") var created_by: String @Field(key: "created_at") var created_at: Int @Field(key: "content") var content: String @Field(key: "title") var title: String @Field(key: "public") var pub: Bool @Field(key: "whitelist") var whitelist: String init() { } init(created_by: String, content: String, title: String, pub: Bool) { self.id = UUID.generateRandom() self.created_by = created_by self.content = content self.title = title self.pub = pub self.whitelist = "" self.created_at = Int(Date().timeIntervalSince1970) } }