定义整数类型的数据,但 return 具有 node.js 模型的字符串类型数据

define a integer type of data but return a string type data with node.js model

我在我的 node.js 模型中定义了一些整数类型的数据:

module.exports = function (sequelize, DataTypes) {
    var Comments = sequelize.define('Comments', {
        id : {type : DataTypes.INTEGER, autoIncrement : true, primaryKey : true, unique : true},
        comment:{type:DataTypes.STRING},
        content:{type:DataTypes.STRING},
        professional: {type:DataTypes.INTEGER},//专业
        attitude: {type:DataTypes.INTEGER},//态度
        satisfaction:{type:DataTypes.INTEGER}//满意度

    },{
        classMethods: {
            associate: function (models) {
                Comments.belongsTo(models.Appointment);
                Comments.belongsTo(models.User,{as:"teacher"});
                Comments.belongsTo(models.User,{as:"student"});
                return;
            }
        }
    });
    return Comments;
}

,但在我使用 sequelize 创建新模型后

    this.addComment = function(model) {
      return models.Comments.create(model);
    }

数据return变成字符串 enter image description here

谁能解释这是为什么?谢谢

好吧,这很奇怪,因为你的代码是正确的,我得到了这样的结果,查看 https://github.com/finfort/SequelizeTestRepo