node.js - 有没有办法将类应用于 Sequelize 模型中的 JSON 属性?
问题描述
const Payments = sequelize.define('Payments', {
id: DataTypes.STRING,
meta: DataTypes.JSON,
}, {
timestamps: false,
})
async function init() {
await sequelize.drop()
await sequelize.sync({ force: true })
const payment = await Payments.create({
id: 'payment-id',
meta: {
status: 'authorized',
history: {
'some-time-stamp': 'some message from service',
'another-time-stamp': 'payment was received by this guy'
}
}
})
}
Sequelize 是否有办法meta
在加载实例时自动将类应用于 JSON 字段?
解决方案
推荐阅读
- python - 在 p4a apk 上出现错误
- powerbi - 我无法在另一个系统中打开我的 pbix 文件
- java - 我正在尝试制作一个循环
- amazon-web-services - Hashicorp 打包程序:如何在首次运行时初始化实例?
- reactjs - 我可以防止 react 返回根 div 吗?
- node.js - 在写入流之前添加转换
- javascript - JavaScript 中的数据处理
- python - 从 Google Sheets API 读取具有正确格式的数字数据
- sql-server - 将 SSIS 包升级到 SQL 2019
- java - 尝试使用 Gradle 构建 JAR 时出现错误“无法将提供的表示法转换为文件或 URI”