我正在尝试使用Vapor创建Model
,而在prepare
方法中,我似乎无法弄清楚如何在语句中添加一些数据类型。
查看Vapor源代码,似乎可以存储一些数据类型:
extension Schema {
/**
Various types of fields
that can be used in a Schema.
*/
public struct Field {
public var name: String
public var type: DataType
public var optional: Bool
public enum DataType {
case id
case int
case string(length: Int?)
case double
case bool
case data
}
public init(name: String, type: DataType, optional: Bool = false) {
self.name = name
self.type = type
self.optional = optional
}
}
}
因此可以存储Int,String(VARCHAR
),Double,Bool和Data(BLOB
)等数据类型,但我找不到我想要的那些,具体来说:
SMALLINT
(UInt16
)DATETIME
DECIMAL
(The MySQL Decimal,非Double或Float)我如何制作这些?