mysql - Swift Vapor/Fluent 模型中的其他数据类型(例如 Unsigned SmallInt、Datetime 和 Decimal)?

标签 mysql swift vapor

我正在尝试用 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)
  • 日期时间
  • DECIMAL(The MySQL Decimal,不是 double 或 float )

我将如何制作这些?

最佳答案

目前,该功能在 Vapor/Fluent 中不存在,但是它是 in the making .

这是 the issues page of Vapor regarding DATETIME

关于mysql - Swift Vapor/Fluent 模型中的其他数据类型(例如 Unsigned SmallInt、Datetime 和 Decimal)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40807228/

相关文章:

laravel - 使用 Vapor 时如何引用 .vue 文件中的资源?

Swift - 获取 XML 属性

ios - 当我不断向 View 添加标签时, ScrollView 不起作用

swift - 错误 : Could not build CSQLiteMac in Vapor

swift - 是否可以在 Swift 2.2 中使用 Vapor Web 框架?

ios - UITableview swift 中的 UITextview 高度

mysql - 在具有多列的一个查询中选择两个查询

mysql - 连接具有多个相同 ID 的表的表

php - 错误代码 1582 : Incorrect parameter count in the call to native function 'FROM_UNIXTIME'

mysql本地安装mysql_install_db错误