sequelize.js - 在 sequelize-typescript 中涉及另一个字段来设置功能
问题描述
问题是我无法访问其他不同类型的字段。在注释列中,set 函数可以访问 name 列但无法访问 num 列并在我尝试记录或使用 setDataValue 时给出未定义。有什么解决方案吗?
@Column({
type: DataType.STRING,
allowNull: false,
})
name: string;
@Column({
type: DataType.INTEGER,
allowNull: false,
})
num: number;
@Column({
type: DataType.STRING,
allowNull: false,
})
set comment(value: string) {
console.log(this.name);
console.log(this.num);
console.log(this.getDataValue('name'));
console.log(this.getDataValue('num'));
this.setDataValue('comment', value + this.name);
}
这是控制台输出:test123, undefined, test123, undefined,
解决方案
推荐阅读
- f# - 在 F# 中添加两个元组
- java - 如何使用自定义方法在链表的第 0 位插入节点?
- c++ - 由于类后的分号导致内部编译器错误
- node.js - EJS 中的 Header 部分问题
- python-3.x - LSTM Keras 中的多个功能
- sharepoint - 如何使用 SharePoint PnP 获取 SharePoint 2013 上的网站集列表
- javascript - If 语句查找数字字段是否留空或小数位数过多,但如果小数位仅为零则忽略
- flutter - Flutter 错误:- 调用 dispose 后不应使用 AnimationController 方法
- javascript - 检查字符串是否以提供的参数结尾
- php - Laravel 7 从数据库和磁盘中删除数组或单个图像 - 从数据库或磁盘中删除帖子但不关联图像