【问题标题】:How to define "TINYINT" datatype with the size in sails.js model file如何使用sails.js模型文件中的大小定义“TINYINT”数据类型
【发布时间】:2019-09-03 21:35:29
【问题描述】:

我有一个 student 表,其中我使用 school_id 列来存储该特定学生的学校 ID,而 school_id 列应该只存储 1 到 20 的值。所以对我来说,TINYINT 是列 school_id 的完美 MySQL 数据类型。但是我在sails.js v0.12的模型文件中没有找到任何定义TINYINT的选项。如何在我的模型文件中定义 TINYINT

我尝试了很多组合,但没有一种组合适合我。

module.exports = {
   attributes: {
      student_id: {
        type: 'integer',
        size: 1,
    },
  }
};

【问题讨论】:

    标签: mysql sails.js


    【解决方案1】:

    你可以这样做:

    module.exports = {
           attributes: {
              student_id: {
                type: 'number',
                columnType: 'tinyint(1)'
            },
          }
        };
    

    或:

    module.exports = {
               attributes: {
                  student_id: {
                    type: 'number',
                    columnType: 'integer(1)'
                },
              }
            };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 2022-01-18
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多