1
我試圖用Vapor創建一個Model
,並且在prepare
方法中,我似乎無法弄清楚如何在語句中添加一些數據類型。Swift Vapor/Fluent模型中的其他數據類型(例如Unsigned SmallInt,Datetime和Decimal)?
展望蒸氣源代碼,似乎是可以存儲一些數據類型:
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,字符串(VARCHAR
),雙,布爾和數據(BLOB
)數據類型可以是存儲,但我無法找到我要找的那些,具體爲:
- 無符號
SMALLINT
(UInt16
) DATETIME
DECIMAL
(The MySQL Decimal,不是雙重或浮動)
我怎麼會做這些?