2017-04-07 111 views
1

我想知道如何在使用sails-mysql的水线模型中定义bigint类型?找不到任何适当的文档。似乎它不支持bigint类型,但我真的需要它。试图挖掘源代码我发现了一些谎言: https://github.com/balderdashy/sails-mysql/blob/987f4674785970951bc52becdfdb479864106da1/helpers/private/schema/build-schema.js#L29 但它仍然无法正常工作。Waterline BIGINT type with sails-mysql

module.exports = { 
    attributes: { 

     userId: { 
      type: 'bigint', 
      autoIncrement: true, 
      primaryKey: true, 
      unique: true, 
     }, 
    } 
}; 

这一个仍然不断创建一个整数字段在数据库中。

回答

2

确定在挖掘源代码之后,我发现我必须为该字段设置一个名为大小的额外属性。将其设置为64将导致水线创建一个BIGINT字段。

module.exports = { 
    attributes: { 

     userId: { 
      type: 'integer', 
      size: 64, // waterline will translate this as bigint 
      autoIncrement: true, 
      primaryKey: true, 
      unique: true, 
     }, 
    } 
}; 
相关问题