【问题标题】:Additional Data types (such as Unsigned SmallInt, Datetime and Decimal) in Swift Vapor/Fluent Model?Swift Vapor/Fluent 模型中的其他数据类型(例如 Unsigned SmallInt、Datetime 和 Decimal)?
【发布时间】:2017-04-09 23:41:11
【问题描述】:

我正在尝试使用 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
  • DECIMALThe MySQL Decimal,不是 Double 或 Float)

我将如何制作这些?

【问题讨论】:

    标签: mysql swift vapor


    【解决方案1】:

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

    这里是the issues page of Vapor regarding DATETIME

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 2021-02-18
      • 1970-01-01
      • 2019-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多