gpt4 book ai didi

javascript - 定义整数类型的数据,但使用 node.js 模型返回字符串类型的数据

转载 作者:行者123 更新时间:2023-12-03 22:42:26 26 4
gpt4 key购买 nike

我在 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);
}


数据返回变成字符串
enter image description here

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

最佳答案

好吧,这很奇怪,因为您的代码是正确的,我已经得到了这样的结果,请查看 https://github.com/finfort/SequelizeTestRepo enter image description here

关于javascript - 定义整数类型的数据,但使用 node.js 模型返回字符串类型的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33954145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com