私はVapor 2を使用しており、非最終モデルを作成してサブクラス化しようとしています。出来ますか?Vapor 2、Fluent modelサブクラス
class MongoObject: Model, JSONRepresentable {
let storage = Storage()
let creationDate: Date
init() {
creationDate = Date()
}
required init(row: Row) throws {
creationDate = try row.get(KeyPath.creationDate)
}
func makeRow() throws -> Row {
var row = Row()
try row.set(KeyPath.creationDate, creationDate)
return row
}
func makeJSON() throws -> JSON {
var json = JSON()
try json.set(KeyPath.id, id)
try json.set(KeyPath.creationDate, creationDate)
return json
}
}
extension MongoObject: Preparation {
class func prepare(model: Creator) { }
static func prepare(_ database: Database) throws {
try database.create(self) { (builder) in
builder.id()
builder.date(KeyPath.creationDate)
prepare(model: builder)
}
}
static func revert(_ database: Database) throws {
try database.delete(self)
}
}
が、コンパイル・エラーを得た:サブクラスと
method 'make(for:)' in non-final class 'MongoObject' must return
Self
to conform to protocol 'Parameterizable'